perf callchain: Remove unused callchain_branch_counts
PATCH 1/1 perf callchain: Remove unused callchain_branch_counts
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts() was added in 2016 by commit 3dd029ef9401 ("perf report: Calculate and return the branch flag counting") but unused.
Remove it and it's helpers.
--- tools/perf/util/callchain.c | 71 ------------------------------------- tools/perf/util/callchain.h | 4 --- 2 files changed, 75 deletions(-)
tools/perf/util/callchain.c +0 -71
@@ -1266,77 +1266,6 @@ int callchain_node__fprintf_value(struct callchain_node *node,return 0 ; } -static void callchain_counts_value (struct callchain_node *node, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -struct callchain_list *clist; - -list_for_each_entry (clist, &node->val, list) { -if (branch_count) - *branch_count += clist->branch_count; - -if (predicted_count) - *predicted_count += clist->predicted_count; - -if (abort_count) - *abort_count += clist->abort_count; - -if (cycles_count) - *cycles_count += clist->cycles_count; - } -} - -static int callchain_node_branch_counts_cumul (struct callchain_node *node, -u64 *branch_count, -u64 *predicted_count, -u64 *abort_count, -u64 *cycles_count) -{ -struct callchain_node *child; -struct rb_node *n; - - n =rb_first (&node->rb_root_in); -while (n) { - child = rb_entry(n, struct callchain_node, rb_node_in); - n =rb_next (n); - -callchain_node_branch_counts_cumul (child, branch_count, - predicted_count, - abort_count, - cycles_count); - -callchain_counts_value (child, branch_count, - predicted_count, abort_count, - cycles_count); - } - -return 0 ; -} - -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -if (branch_count) - *branch_count =0 ; - -if (predicted_count) - *predicted_count =0 ; - -if (abort_count) - *abort_count =0 ; - -if (cycles_count) - *cycles_count =0 ; - -return callchain_node_branch_counts_cumul (&root->node, - branch_count, - predicted_count, - abort_count, - cycles_count); -} -static int count_pri64_printf (int idx,const char *str,u64 value,char *bf,int bfsize) {return scnprintf (bf, bfsize,"%s%s:%" PRId64"" , (idx) ?" " :" (" , str, value);
tools/perf/util/callchain.h +0 -4
@@ -298,10 +298,6 @@ void free_callchain(struct callchain_root *root);void decay_callchain (struct callchain_root *root);int callchain_node__make_parent_list (struct callchain_node *node); -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count); -void callchain_param_setup (u64 sample_type,const char *arch); bool callchain_cnode_matched(struct callchain_node *base_cnode,
Signature · 1 line
2.46.2
Namhyung Kim
maintainerQuoted 7 lines · On Sun, Oct 06, 2024 at 02:22:04AM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts()was added in 2016 by commit3dd029ef9401("perf report: Calculate and return the branch flag counting") but unused.Remove it and it's helpers.
Kan, are you ok with this?
Thanks,
Namhyung
Quoted 107 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- tools/perf/util/callchain.c | 71 ------------------------------------- tools/perf/util/callchain.h | 4 --- 2 files changed, 75 deletions(-)tools/perf/util/callchain.c +0
-71@@ -1266,77 +1266,6 @@ int callchain_node__fprintf_value(struct callchain_node *node,return 0 ; } -static void callchain_counts_value (struct callchain_node *node, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -struct callchain_list *clist; - -list_for_each_entry (clist, &node->val, list) { -if (branch_count) - *branch_count += clist->branch_count; - -if (predicted_count) - *predicted_count += clist->predicted_count; - -if (abort_count) - *abort_count += clist->abort_count; - -if (cycles_count) - *cycles_count += clist->cycles_count; - } -} - -static int callchain_node_branch_counts_cumul (struct callchain_node *node, -u64 *branch_count, -u64 *predicted_count, -u64 *abort_count, -u64 *cycles_count) -{ -struct callchain_node *child; -struct rb_node *n; - - n =rb_first (&node->rb_root_in); -while (n) { - child = rb_entry(n, struct callchain_node, rb_node_in); - n =rb_next (n); - -callchain_node_branch_counts_cumul (child, branch_count, - predicted_count, - abort_count, - cycles_count); - -callchain_counts_value (child, branch_count, - predicted_count, abort_count, - cycles_count); - } - -return 0 ; -} - -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -if (branch_count) - *branch_count =0 ; - -if (predicted_count) - *predicted_count =0 ; - -if (abort_count) - *abort_count =0 ; - -if (cycles_count) - *cycles_count =0 ; - -return callchain_node_branch_counts_cumul (&root->node, - branch_count, - predicted_count, - abort_count, - cycles_count); -} -static int count_pri64_printf (int idx,const char *str,u64 value,char *bf,int bfsize) {return scnprintf (bf, bfsize,"%s%s:%" PRId64"" , (idx) ?" " :" (" , str, value);tools/perf/util/callchain.h +0
-4@@ -298,10 +298,6 @@ void free_callchain(struct callchain_root *root);void decay_callchain (struct callchain_root *root);int callchain_node__make_parent_list (struct callchain_node *node); -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count); -void callchain_param_setup (u64 sample_type,const char *arch); bool callchain_cnode_matched(struct callchain_node *base_cnode,Signature · 1 line
2.46.2
Quoted 6 lines · Namhyung Kim
Quoted 5 lines · On Sun, Oct 06, 2024 at 02:22:04AM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts()was added in 2016 by commit3dd029ef9401("perf report: Calculate and return the branch flag counting") but unused.
It seems the original patchset was not well organized. This function is actually used by the last patch of the series.
https://lore.kernel.org/lkml/[email protected]/
But for some reason, the last patch was not merged. I think Andi gave the Acked-by for the whole series. It might be just accidentally missed.
I think the missed feature is still useful.
We will redo the test and re-post it.
Thanks,
Kan
Quoted 116 lines
Quoted 2 lines
Remove it and it's helpers.
Kan, are you ok with this?
Thanks,
NamhyungQuoted 107 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- tools/perf/util/callchain.c | 71 ------------------------------------- tools/perf/util/callchain.h | 4 --- 2 files changed, 75 deletions(-)tools/perf/util/callchain.c +0
-71@@ -1266,77 +1266,6 @@ int callchain_node__fprintf_value(struct callchain_node *node,return 0 ; } -static void callchain_counts_value (struct callchain_node *node, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -struct callchain_list *clist; - -list_for_each_entry (clist, &node->val, list) { -if (branch_count) - *branch_count += clist->branch_count; - -if (predicted_count) - *predicted_count += clist->predicted_count; - -if (abort_count) - *abort_count += clist->abort_count; - -if (cycles_count) - *cycles_count += clist->cycles_count; - } -} - -static int callchain_node_branch_counts_cumul (struct callchain_node *node, -u64 *branch_count, -u64 *predicted_count, -u64 *abort_count, -u64 *cycles_count) -{ -struct callchain_node *child; -struct rb_node *n; - - n =rb_first (&node->rb_root_in); -while (n) { - child = rb_entry(n, struct callchain_node, rb_node_in); - n =rb_next (n); - -callchain_node_branch_counts_cumul (child, branch_count, - predicted_count, - abort_count, - cycles_count); - -callchain_counts_value (child, branch_count, - predicted_count, abort_count, - cycles_count); - } - -return 0 ; -} - -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -if (branch_count) - *branch_count =0 ; - -if (predicted_count) - *predicted_count =0 ; - -if (abort_count) - *abort_count =0 ; - -if (cycles_count) - *cycles_count =0 ; - -return callchain_node_branch_counts_cumul (&root->node, - branch_count, - predicted_count, - abort_count, - cycles_count); -} -static int count_pri64_printf (int idx,const char *str,u64 value,char *bf,int bfsize) {return scnprintf (bf, bfsize,"%s%s:%" PRId64"" , (idx) ?" " :" (" , str, value);tools/perf/util/callchain.h +0
-4@@ -298,10 +298,6 @@ void free_callchain(struct callchain_root *root);void decay_callchain (struct callchain_root *root);int callchain_node__make_parent_list (struct callchain_node *node); -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count); -void callchain_param_setup (u64 sample_type,const char *arch); bool callchain_cnode_matched(struct callchain_node *base_cnode,Signature · 1 line
2.46.2
Quoted 10 lines · * Liang, Kan ([email protected]) wrote:
Quoted 6 lines · Namhyung Kim
Quoted 5 lines · On Sun, Oct 06, 2024 at 02:22:04AM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts()was added in 2016 by commit3dd029ef9401("perf report: Calculate and return the branch flag counting") but unused.
Quoted 6 lines
It seems the original patchset was not well organized. This function is actually used by the last patch of the series.
https://lore.kernel.org/lkml/[email protected]/But for some reason, the last patch was not merged. I think Andi gave the Acked-by for the whole series. It might be just accidentally missed.
OK, that'll be the 4th time this deadcode series has found missing calls to functions!
Quoted 2 lines
I think the missed feature is still useful.
We will redo the test and re-post it.
OK, great.
Dave
Quoted 120 lines
Thanks,
KanQuoted 116 lines
Quoted 2 lines
Remove it and it's helpers.
Kan, are you ok with this?
Thanks,
NamhyungQuoted 107 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- tools/perf/util/callchain.c | 71 ------------------------------------- tools/perf/util/callchain.h | 4 --- 2 files changed, 75 deletions(-)tools/perf/util/callchain.c +0
-71@@ -1266,77 +1266,6 @@ int callchain_node__fprintf_value(struct callchain_node *node,return 0 ; } -static void callchain_counts_value (struct callchain_node *node, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -struct callchain_list *clist; - -list_for_each_entry (clist, &node->val, list) { -if (branch_count) - *branch_count += clist->branch_count; - -if (predicted_count) - *predicted_count += clist->predicted_count; - -if (abort_count) - *abort_count += clist->abort_count; - -if (cycles_count) - *cycles_count += clist->cycles_count; - } -} - -static int callchain_node_branch_counts_cumul (struct callchain_node *node, -u64 *branch_count, -u64 *predicted_count, -u64 *abort_count, -u64 *cycles_count) -{ -struct callchain_node *child; -struct rb_node *n; - - n =rb_first (&node->rb_root_in); -while (n) { - child = rb_entry(n, struct callchain_node, rb_node_in); - n =rb_next (n); - -callchain_node_branch_counts_cumul (child, branch_count, - predicted_count, - abort_count, - cycles_count); - -callchain_counts_value (child, branch_count, - predicted_count, abort_count, - cycles_count); - } - -return 0 ; -} - -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count) -{ -if (branch_count) - *branch_count =0 ; - -if (predicted_count) - *predicted_count =0 ; - -if (abort_count) - *abort_count =0 ; - -if (cycles_count) - *cycles_count =0 ; - -return callchain_node_branch_counts_cumul (&root->node, - branch_count, - predicted_count, - abort_count, - cycles_count); -} -static int count_pri64_printf (int idx,const char *str,u64 value,char *bf,int bfsize) {return scnprintf (bf, bfsize,"%s%s:%" PRId64"" , (idx) ?" " :" (" , str, value);tools/perf/util/callchain.h +0
-4@@ -298,10 +298,6 @@ void free_callchain(struct callchain_root *root);void decay_callchain (struct callchain_root *root);int callchain_node__make_parent_list (struct callchain_node *node); -int callchain_branch_counts (struct callchain_root *root, -u64 *branch_count,u64 *predicted_count, -u64 *abort_count,u64 *cycles_count); -void callchain_param_setup (u64 sample_type,const char *arch); bool callchain_cnode_matched(struct callchain_node *base_cnode,Signature · 1 line
2.46.2
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Namhyung Kim
maintainerQuoted 15 lines · Dr. David Alan Gilbert
Quoted 14 lines · * Liang, Kan ([email protected]) wrote:
Quoted 6 lines · Namhyung Kim
Quoted 5 lines · On Sun, Oct 06, 2024 at 02:22:04AM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts()was added in 2016 by commit3dd029ef9401("perf report: Calculate and return the branch flag counting") but unused.It seems the original patchset was not well organized. This function is actually used by the last patch of the series.
https://lore.kernel.org/lkml/[email protected]/
Quoted 5 lines
Quoted 2 lines
But for some reason, the last patch was not merged. I think Andi gave the Acked-by for the whole series. It might be just accidentally missed.
OK, that'll be the 4th time this deadcode series has found missing calls to functions!
Nice work! :)
Thanks,
Namhyung
Namhyung Kim
maintainerQuoted 14 lines · Kan
Quoted 6 lines · Namhyung Kim
Quoted 5 lines · On Sun, Oct 06, 2024 at 02:22:04AM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
callchain_branch_counts()was added in 2016 by commit3dd029ef9401("perf report: Calculate and return the branch flag counting") but unused.It seems the original patchset was not well organized. This function is actually used by the last patch of the series.
https://lore.kernel.org/lkml/[email protected]/
Quoted 5 lines
But for some reason, the last patch was not merged. I think Andi gave the Acked-by for the whole series. It might be just accidentally missed.
I think the missed feature is still useful.
We will redo the test and re-post it.
Great, thanks for taking care of this.
Namhyung
PATCH 1/1 perf report: Display columns Predicted/Abort/Cycles in --branch-history
The original commit message:
"
Use current sort mechanism but the real .se_cmp() just returns 0 so that new columns "Predicted", "Abort" and "Cycles" are created in display but actually these keys are not the sort keys.
For example:
Overhead Source:Line Symbol Shared Object Predicted Abort Cycles ........ ............ ........ ............. ......... ..... ......
38.25% div.c:45 [.] main div 97.6% 0 3
"
Update missed commit from series "perf report: Show branch flags/cycles in --branch-history callgraph view" to apply to current repository so that new columns described above are visible.
Link to original series:
https://lore.kernel.org/lkml/[email protected]/
--- tools/perf/Documentation/perf-report.txt | 8 ++ tools/perf/builtin-report.c | 6 +- tools/perf/util/hist.c | 3 + tools/perf/util/hist.h | 3 + tools/perf/util/sort.c | 113 ++++++++++++++++++++++- tools/perf/util/sort.h | 3 + 6 files changed, 134 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +8 -0
@@ -391,6 +391,14 @@ OPTIONS This allows to examine the path the program took to each sample. The data collection must have used -b (or -j) and -g. + Also show with some branch flags that can be: + - Predicted: display the average percentage of predicated branches. + (predicated number / total number) + - Abort: display the number of tsx aborted branches. + - Cycles: cycles in basic block. + + - iterations: display the average number of iterations in callchain list. + --addr2line=<path>:: Path to addr2line binary.
tools/perf/builtin-report.c +5 -1
@@ -1271,6 +1271,10 @@ static int process_attr(const struct perf_tool *tool __maybe_unused,return 0 ; } +#define CALLCHAIN_BRANCH_SORT_ORDER \ + "srcline,symbol,dso,callchain_branch_predicted," \ + "callchain_branch_abort,callchain_branch_cycles" +int cmd_report (int argc,const char **argv) {struct perf_session *session;
@@ -1639,7 +1643,7 @@ int cmd_report(int argc, const char **argv) symbol_conf.use_callchain = true;callchain_register_param (&callchain_param);if (sort_order ==NULL ) - sort_order ="srcline,symbol,dso" ; + sort_order =CALLCHAIN_BRANCH_SORT_ORDER ; }if (report.mem_mode) {
tools/perf/util/hist.c +3 -0
@@ -218,6 +218,9 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)hists__new_col_len (hists,HISTC_LOCAL_P_STAGE_CYC ,13 );hists__new_col_len (hists,HISTC_GLOBAL_P_STAGE_CYC ,13 );hists__new_col_len (hists,HISTC_ADDR ,BITS_PER_LONG /4 +2 ); +hists__new_col_len (hists,HISTC_CALLCHAIN_BRANCH_PREDICTED ,9 ); +hists__new_col_len (hists,HISTC_CALLCHAIN_BRANCH_ABORT ,5 ); +hists__new_col_len (hists,HISTC_CALLCHAIN_BRANCH_CYCLES ,6 );if (symbol_conf.nanosecs)hists__new_col_len (hists,HISTC_TIME ,16 );
tools/perf/util/hist.h +3 -0
@@ -87,6 +87,9 @@ enum hist_column {HISTC_TYPE_OFFSET ,HISTC_SYMBOL_OFFSET ,HISTC_TYPE_CACHELINE , +HISTC_CALLCHAIN_BRANCH_PREDICTED , +HISTC_CALLCHAIN_BRANCH_ABORT , +HISTC_CALLCHAIN_BRANCH_CYCLES , HISTC_NR_COLS, /* Last entry */ };
tools/perf/util/sort.c +112 -1
131 lines not on this page · raw message
tools/perf/util/sort.h +3 -0
@@ -88,6 +88,9 @@ enum sort_type {SORT_SYM_IPC ,SORT_ADDR_FROM ,SORT_ADDR_TO , +SORT_CALLCHAIN_BRANCH_PREDICTED , +SORT_CALLCHAIN_BRANCH_ABORT , +SORT_CALLCHAIN_BRANCH_CYCLES ,/* memory mode specific sort keys */ __SORT_MEMORY_MODE,
Signature · 1 line
2.47.0
Re: [PATCH] perf report: Display columns Predicted/Abort/Cycles in --branch-history
Quoted 8 lines · Thomas Falcon
The original commit message:
"
Use current sort mechanism but the real .se_cmp() just returns 0 so that new columns "Predicted", "Abort" and "Cycles" are created in display but actually these keys are not the sort keys.[...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung