diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-03-07 14:44:50 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-03-08 04:11:21 -0500 |
commit | a61a22f6845f9e86e0ca60d1d256a35ca12312ef (patch) | |
tree | 054b091b946bb7152feeb753554751975dc20d31 | |
parent | f58c95e344c26223c6503e6ecb0c1e11806d91e0 (diff) |
perf hists browser: Use hierarchy hpp list
Now hpp formats are linked using perf_hpp_list_node when hierarchy is
enabled. Like in stdio, use this info to print entries with multiple
sort keys in a single hierarchy properly.
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1457361308-514-7-git-send-email-namhyung@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 2f02ce79bd9d..e0e217ec856b 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1289,6 +1289,7 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, | |||
1289 | off_t row_offset = entry->row_offset; | 1289 | off_t row_offset = entry->row_offset; |
1290 | bool first = true; | 1290 | bool first = true; |
1291 | struct perf_hpp_fmt *fmt; | 1291 | struct perf_hpp_fmt *fmt; |
1292 | struct perf_hpp_list_node *fmt_node; | ||
1292 | struct hpp_arg arg = { | 1293 | struct hpp_arg arg = { |
1293 | .b = &browser->b, | 1294 | .b = &browser->b, |
1294 | .current_entry = current_entry, | 1295 | .current_entry = current_entry, |
@@ -1320,7 +1321,10 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, | |||
1320 | ui_browser__write_nstring(&browser->b, "", level * HIERARCHY_INDENT); | 1321 | ui_browser__write_nstring(&browser->b, "", level * HIERARCHY_INDENT); |
1321 | width -= level * HIERARCHY_INDENT; | 1322 | width -= level * HIERARCHY_INDENT; |
1322 | 1323 | ||
1323 | hists__for_each_format(entry->hists, fmt) { | 1324 | /* the first hpp_list_node is for overhead columns */ |
1325 | fmt_node = list_first_entry(&entry->hists->hpp_formats, | ||
1326 | struct perf_hpp_list_node, list); | ||
1327 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { | ||
1324 | char s[2048]; | 1328 | char s[2048]; |
1325 | struct perf_hpp hpp = { | 1329 | struct perf_hpp hpp = { |
1326 | .buf = s, | 1330 | .buf = s, |
@@ -1332,10 +1336,6 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, | |||
1332 | column++ < browser->b.horiz_scroll) | 1336 | column++ < browser->b.horiz_scroll) |
1333 | continue; | 1337 | continue; |
1334 | 1338 | ||
1335 | if (perf_hpp__is_sort_entry(fmt) || | ||
1336 | perf_hpp__is_dynamic_entry(fmt)) | ||
1337 | break; | ||
1338 | |||
1339 | if (current_entry && browser->b.navkeypressed) { | 1339 | if (current_entry && browser->b.navkeypressed) { |
1340 | ui_browser__set_color(&browser->b, | 1340 | ui_browser__set_color(&browser->b, |
1341 | HE_COLORSET_SELECTED); | 1341 | HE_COLORSET_SELECTED); |
@@ -1444,6 +1444,7 @@ static int hist_browser__show_no_entry(struct hist_browser *browser, | |||
1444 | int column = 0; | 1444 | int column = 0; |
1445 | int ret; | 1445 | int ret; |
1446 | struct perf_hpp_fmt *fmt; | 1446 | struct perf_hpp_fmt *fmt; |
1447 | struct perf_hpp_list_node *fmt_node; | ||
1447 | int indent = browser->hists->nr_hpp_node - 2; | 1448 | int indent = browser->hists->nr_hpp_node - 2; |
1448 | 1449 | ||
1449 | if (current_entry) { | 1450 | if (current_entry) { |
@@ -1461,15 +1462,14 @@ static int hist_browser__show_no_entry(struct hist_browser *browser, | |||
1461 | ui_browser__write_nstring(&browser->b, "", level * HIERARCHY_INDENT); | 1462 | ui_browser__write_nstring(&browser->b, "", level * HIERARCHY_INDENT); |
1462 | width -= level * HIERARCHY_INDENT; | 1463 | width -= level * HIERARCHY_INDENT; |
1463 | 1464 | ||
1464 | hists__for_each_format(browser->hists, fmt) { | 1465 | /* the first hpp_list_node is for overhead columns */ |
1466 | fmt_node = list_first_entry(&browser->hists->hpp_formats, | ||
1467 | struct perf_hpp_list_node, list); | ||
1468 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { | ||
1465 | if (perf_hpp__should_skip(fmt, browser->hists) || | 1469 | if (perf_hpp__should_skip(fmt, browser->hists) || |
1466 | column++ < browser->b.horiz_scroll) | 1470 | column++ < browser->b.horiz_scroll) |
1467 | continue; | 1471 | continue; |
1468 | 1472 | ||
1469 | if (perf_hpp__is_sort_entry(fmt) || | ||
1470 | perf_hpp__is_dynamic_entry(fmt)) | ||
1471 | break; | ||
1472 | |||
1473 | ret = fmt->width(fmt, NULL, hists_to_evsel(browser->hists)); | 1473 | ret = fmt->width(fmt, NULL, hists_to_evsel(browser->hists)); |
1474 | 1474 | ||
1475 | if (first) { | 1475 | if (first) { |
@@ -1551,22 +1551,23 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows | |||
1551 | .size = size, | 1551 | .size = size, |
1552 | }; | 1552 | }; |
1553 | struct perf_hpp_fmt *fmt; | 1553 | struct perf_hpp_fmt *fmt; |
1554 | struct perf_hpp_list_node *fmt_node; | ||
1554 | size_t ret = 0; | 1555 | size_t ret = 0; |
1555 | int column = 0; | 1556 | int column = 0; |
1556 | int indent = hists->nr_hpp_node - 2; | 1557 | int indent = hists->nr_hpp_node - 2; |
1557 | bool first = true; | 1558 | bool first_node, first_col; |
1558 | 1559 | ||
1559 | ret = scnprintf(buf, size, " "); | 1560 | ret = scnprintf(buf, size, " "); |
1560 | if (advance_hpp_check(&dummy_hpp, ret)) | 1561 | if (advance_hpp_check(&dummy_hpp, ret)) |
1561 | return ret; | 1562 | return ret; |
1562 | 1563 | ||
1563 | hists__for_each_format(hists, fmt) { | 1564 | /* the first hpp_list_node is for overhead columns */ |
1565 | fmt_node = list_first_entry(&hists->hpp_formats, | ||
1566 | struct perf_hpp_list_node, list); | ||
1567 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { | ||
1564 | if (column++ < browser->b.horiz_scroll) | 1568 | if (column++ < browser->b.horiz_scroll) |
1565 | continue; | 1569 | continue; |
1566 | 1570 | ||
1567 | if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt)) | ||
1568 | break; | ||
1569 | |||
1570 | ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); | 1571 | ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); |
1571 | if (advance_hpp_check(&dummy_hpp, ret)) | 1572 | if (advance_hpp_check(&dummy_hpp, ret)) |
1572 | break; | 1573 | break; |
@@ -1581,34 +1582,42 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows | |||
1581 | if (advance_hpp_check(&dummy_hpp, ret)) | 1582 | if (advance_hpp_check(&dummy_hpp, ret)) |
1582 | return ret; | 1583 | return ret; |
1583 | 1584 | ||
1584 | hists__for_each_format(hists, fmt) { | 1585 | first_node = true; |
1585 | char *start; | 1586 | list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) { |
1586 | 1587 | if (!first_node) { | |
1587 | if (!perf_hpp__is_sort_entry(fmt) && !perf_hpp__is_dynamic_entry(fmt)) | ||
1588 | continue; | ||
1589 | if (perf_hpp__should_skip(fmt, hists)) | ||
1590 | continue; | ||
1591 | |||
1592 | if (first) { | ||
1593 | first = false; | ||
1594 | } else { | ||
1595 | ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " / "); | 1588 | ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " / "); |
1596 | if (advance_hpp_check(&dummy_hpp, ret)) | 1589 | if (advance_hpp_check(&dummy_hpp, ret)) |
1597 | break; | 1590 | break; |
1598 | } | 1591 | } |
1592 | first_node = false; | ||
1599 | 1593 | ||
1600 | ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); | 1594 | first_col = true; |
1601 | dummy_hpp.buf[ret] = '\0'; | 1595 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { |
1602 | rtrim(dummy_hpp.buf); | 1596 | char *start; |
1603 | 1597 | ||
1604 | start = ltrim(dummy_hpp.buf); | 1598 | if (perf_hpp__should_skip(fmt, hists)) |
1605 | ret = strlen(start); | 1599 | continue; |
1606 | 1600 | ||
1607 | if (start != dummy_hpp.buf) | 1601 | if (!first_col) { |
1608 | memmove(dummy_hpp.buf, start, ret + 1); | 1602 | ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "+"); |
1603 | if (advance_hpp_check(&dummy_hpp, ret)) | ||
1604 | break; | ||
1605 | } | ||
1606 | first_col = false; | ||
1609 | 1607 | ||
1610 | if (advance_hpp_check(&dummy_hpp, ret)) | 1608 | ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); |
1611 | break; | 1609 | dummy_hpp.buf[ret] = '\0'; |
1610 | rtrim(dummy_hpp.buf); | ||
1611 | |||
1612 | start = ltrim(dummy_hpp.buf); | ||
1613 | ret = strlen(start); | ||
1614 | |||
1615 | if (start != dummy_hpp.buf) | ||
1616 | memmove(dummy_hpp.buf, start, ret + 1); | ||
1617 | |||
1618 | if (advance_hpp_check(&dummy_hpp, ret)) | ||
1619 | break; | ||
1620 | } | ||
1612 | } | 1621 | } |
1613 | 1622 | ||
1614 | return ret; | 1623 | return ret; |
@@ -1676,7 +1685,7 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
1676 | break; | 1685 | break; |
1677 | 1686 | ||
1678 | if (h->has_no_entry) { | 1687 | if (h->has_no_entry) { |
1679 | hist_browser__show_no_entry(hb, row, h->depth); | 1688 | hist_browser__show_no_entry(hb, row, h->depth + 1); |
1680 | row++; | 1689 | row++; |
1681 | } | 1690 | } |
1682 | } else { | 1691 | } else { |