Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf hists: Add support for header span

Add span argument for header callback function.

The handling of this argument is completely in the hands of the
callback. The only thing the caller ensures is it's zeroed on the
beginning.

Omitting span skipping in hierarchy headers and gtk code.

The c2c code use this to span header lines based on the entries span
configuration.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1470583710-1649-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
29659ab4 f3705b06

+25 -14
+2 -1
tools/perf/builtin-diff.c
··· 1034 1034 1035 1035 static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1036 1036 struct hists *hists __maybe_unused, 1037 - int line __maybe_unused) 1037 + int line __maybe_unused, 1038 + int *span __maybe_unused) 1038 1039 { 1039 1040 struct diff_hpp_fmt *dfmt = 1040 1041 container_of(fmt, struct diff_hpp_fmt, fmt);
+7 -3
tools/perf/ui/browsers/hists.c
··· 1514 1514 struct perf_hpp_fmt *fmt; 1515 1515 size_t ret = 0; 1516 1516 int column = 0; 1517 + int span = 0; 1517 1518 1518 1519 if (symbol_conf.use_callchain) { 1519 1520 ret = scnprintf(buf, size, " "); ··· 1526 1525 if (perf_hpp__should_skip(fmt, hists) || column++ < browser->b.horiz_scroll) 1527 1526 continue; 1528 1527 1529 - ret = fmt->header(fmt, &dummy_hpp, hists, line); 1528 + ret = fmt->header(fmt, &dummy_hpp, hists, line, &span); 1530 1529 if (advance_hpp_check(&dummy_hpp, ret)) 1531 1530 break; 1531 + 1532 + if (span) 1533 + continue; 1532 1534 1533 1535 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " "); 1534 1536 if (advance_hpp_check(&dummy_hpp, ret)) ··· 1566 1562 if (column++ < browser->b.horiz_scroll) 1567 1563 continue; 1568 1564 1569 - ret = fmt->header(fmt, &dummy_hpp, hists, 0); 1565 + ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL); 1570 1566 if (advance_hpp_check(&dummy_hpp, ret)) 1571 1567 break; 1572 1568 ··· 1603 1599 } 1604 1600 first_col = false; 1605 1601 1606 - ret = fmt->header(fmt, &dummy_hpp, hists, 0); 1602 + ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL); 1607 1603 dummy_hpp.buf[ret] = '\0'; 1608 1604 1609 1605 start = trim(dummy_hpp.buf);
+1 -1
tools/perf/ui/gtk/hists.c
··· 549 549 strcat(buf, "+"); 550 550 first_col = false; 551 551 552 - fmt->header(fmt, &hpp, hists, 0); 552 + fmt->header(fmt, &hpp, hists, 0, NULL); 553 553 strcat(buf, ltrim(rtrim(hpp.buf))); 554 554 } 555 555 }
+2 -1
tools/perf/ui/hist.c
··· 230 230 } 231 231 232 232 static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 233 - struct hists *hists, int line __maybe_unused) 233 + struct hists *hists, int line __maybe_unused, 234 + int *span __maybe_unused) 234 235 { 235 236 int len = hpp__width_fn(fmt, hpp, hists); 236 237 return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name);
+8 -5
tools/perf/ui/stdio/hist.c
··· 549 549 struct perf_hpp_list_node, list); 550 550 551 551 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { 552 - fmt->header(fmt, hpp, hists, 0); 552 + fmt->header(fmt, hpp, hists, 0, NULL); 553 553 fprintf(fp, "%s%s", hpp->buf, sep ?: " "); 554 554 } 555 555 ··· 569 569 header_width += fprintf(fp, "+"); 570 570 first_col = false; 571 571 572 - fmt->header(fmt, hpp, hists, 0); 572 + fmt->header(fmt, hpp, hists, 0, NULL); 573 573 574 574 header_width += fprintf(fp, "%s", trim(hpp->buf)); 575 575 } ··· 645 645 struct perf_hpp_fmt *fmt; 646 646 const char *sep = symbol_conf.field_sep; 647 647 bool first = true; 648 + int span = 0; 648 649 649 650 hists__for_each_format(hists, fmt) { 650 651 if (perf_hpp__should_skip(fmt, hists)) 651 652 continue; 652 653 653 - if (!first) 654 + if (!first && !span) 654 655 fprintf(fp, "%s", sep ?: " "); 655 656 else 656 657 first = false; 657 658 658 - fmt->header(fmt, hpp, hists, line); 659 - fprintf(fp, "%s", hpp->buf); 659 + fmt->header(fmt, hpp, hists, line, &span); 660 + 661 + if (!span) 662 + fprintf(fp, "%s", hpp->buf); 660 663 } 661 664 } 662 665
+1 -1
tools/perf/util/hist.h
··· 230 230 struct perf_hpp_fmt { 231 231 const char *name; 232 232 int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 233 - struct hists *hists, int line); 233 + struct hists *hists, int line, int *span); 234 234 int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 235 235 struct hists *hists); 236 236 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
+4 -2
tools/perf/util/sort.c
··· 1492 1492 } 1493 1493 1494 1494 static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1495 - struct hists *hists, int line __maybe_unused) 1495 + struct hists *hists, int line __maybe_unused, 1496 + int *span __maybe_unused) 1496 1497 { 1497 1498 struct hpp_sort_entry *hse; 1498 1499 size_t len = fmt->user_len; ··· 1799 1798 1800 1799 static int __sort__hde_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1801 1800 struct hists *hists __maybe_unused, 1802 - int line __maybe_unused) 1801 + int line __maybe_unused, 1802 + int *span __maybe_unused) 1803 1803 { 1804 1804 struct hpp_dynamic_entry *hde; 1805 1805 size_t len = fmt->user_len;