Skip to content

Commit abab5e7

Browse files
namhyungacmel
authored andcommitted
perf report: Update column width of dynamic entries
The column width of dynamic entries is updated when comparing hist entries. However some unique entries can miss the chance to update. So move the update to output resort stage to make sure every entry will get called before display. To do that, abuse ->sort callback to update the width when the third argument is NULL. When resorting entries in normal path, it never be NULL so it should be fine IMHO. Before: # Overhead ptr / bytes_req / gfp_flags # .............. .......................................... # 37.50% 0xffff8803f7669400 37.50% 448 37.50% GFP_ATOMIC|GFP_NOWARN|GFP_NOMEMALLOC 10.42% 0xffff8803f766be00 8.33% 96 8.33% GFP_ATOMIC|GFP_NOWARN|GFP_NOMEMALLOC 2.08% 512 2.08% GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP <-- here After: # Overhead ptr / bytes_req / gfp_flags # .............. ..................................................... # 37.50% 0xffff8803f7669400 37.50% 448 37.50% GFP_ATOMIC|GFP_NOWARN|GFP_NOMEMALLOC 10.42% 0xffff8803f766be00 8.33% 96 8.33% GFP_ATOMIC|GFP_NOWARN|GFP_NOMEMALLOC 2.08% 512 2.08% GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC Signed-off-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e049d4a commit abab5e7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tools/perf/util/hist.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,10 @@ static void hierarchy_insert_output_entry(struct rb_root *root,
13711371

13721372
rb_link_node(&he->rb_node, parent, p);
13731373
rb_insert_color(&he->rb_node, root);
1374+
1375+
/* update column width of dynamic entry */
1376+
if (perf_hpp__is_dynamic_entry(he->fmt))
1377+
he->fmt->sort(he->fmt, he, NULL);
13741378
}
13751379

13761380
static void hists__hierarchy_output_resort(struct hists *hists,
@@ -1440,6 +1444,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
14401444
struct rb_node **p = &entries->rb_node;
14411445
struct rb_node *parent = NULL;
14421446
struct hist_entry *iter;
1447+
struct perf_hpp_fmt *fmt;
14431448

14441449
if (use_callchain) {
14451450
if (callchain_param.mode == CHAIN_GRAPH_REL) {
@@ -1466,6 +1471,12 @@ static void __hists__insert_output_entry(struct rb_root *entries,
14661471

14671472
rb_link_node(&he->rb_node, parent, p);
14681473
rb_insert_color(&he->rb_node, entries);
1474+
1475+
perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
1476+
if (perf_hpp__is_dynamic_entry(fmt) &&
1477+
perf_hpp__defined_dynamic_entry(fmt, he->hists))
1478+
fmt->sort(fmt, he, NULL); /* update column width */
1479+
}
14691480
}
14701481

14711482
static void output_resort(struct hists *hists, struct ui_progress *prog,

tools/perf/util/sort.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,11 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
18161816

18171817
hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
18181818

1819+
if (b == NULL) {
1820+
update_dynamic_len(hde, a);
1821+
return 0;
1822+
}
1823+
18191824
field = hde->field;
18201825
if (field->flags & FIELD_IS_DYNAMIC) {
18211826
unsigned long long dyn;
@@ -1830,9 +1835,6 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
18301835
} else {
18311836
offset = field->offset;
18321837
size = field->size;
1833-
1834-
update_dynamic_len(hde, a);
1835-
update_dynamic_len(hde, b);
18361838
}
18371839

18381840
return memcmp(a->raw_data + offset, b->raw_data + offset, size);

0 commit comments

Comments
 (0)