Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1504097 > unrolled thread
| Started by | Jin Yao <yao.jin@linux.intel.com> |
|---|---|
| First post | 2016-10-19 18:30 +0200 |
| Last post | 2016-10-25 20:20 +0200 |
| Articles | 7 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Jin Yao <yao.jin@linux.intel.com> - 2016-10-19 18:30 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Nilay Vaish <nilayvaish@gmail.com> - 2016-10-20 18:50 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Andi Kleen <ak@linux.intel.com> - 2016-10-20 18:50 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Nilay Vaish <nilayvaish@gmail.com> - 2016-10-20 19:10 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Andi Kleen <ak@linux.intel.com> - 2016-10-20 20:30 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain "Jin, Yao" <yao.jin@linux.intel.com> - 2016-10-21 02:30 +0200
Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-25 20:20 +0200
| From | Jin Yao <yao.jin@linux.intel.com> |
|---|---|
| Date | 2016-10-19 18:30 +0200 |
| Subject | [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <su1UD-3KZ-47@gated-at.bofh.it> |
Create some branch counters in per callchain list entry. Each counter
is for a branch flag. For example, predicted_count counts all the
*predicted* branches. The counters get updated by processing the
callchain cursor nodes.
It also provides functions to retrieve or print the values of counters
in callchain list.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
tools/perf/util/callchain.c | 165 +++++++++++++++++++++++++++++++++++++++++++-
tools/perf/util/callchain.h | 11 +++
2 files changed, 175 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 342ef20..8937a2c 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -440,6 +440,19 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
call->ip = cursor_node->ip;
call->ms.sym = cursor_node->sym;
call->ms.map = cursor_node->map;
+
+ if (cursor_node->branch) {
+ call->branch_count = 1;
+
+ if (cursor_node->branch_flags.predicted)
+ call->predicted_count = 1;
+
+ if (cursor_node->branch_flags.abort)
+ call->abort_count = 1;
+
+ call->cycles_count = cursor_node->branch_flags.cycles;
+ }
+
list_add_tail(&call->list, &node->val);
callchain_cursor_advance(cursor);
@@ -499,8 +512,21 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
right = node->ip;
}
- if (left == right)
+ if (left == right) {
+ if (node->branch) {
+ cnode->branch_count++;
+
+ if (node->branch_flags.predicted)
+ cnode->predicted_count++;
+
+ if (node->branch_flags.abort)
+ cnode->abort_count++;
+
+ cnode->cycles_count += node->branch_flags.cycles;
+ }
+
return MATCH_EQ;
+ }
return left > right ? MATCH_GT : MATCH_LT;
}
@@ -946,6 +972,143 @@ 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 callchain_counts_printf(FILE *fp, char *bf, int bfsize,
+ u64 branch_count, u64 predicted_count,
+ u64 abort_count, u64 cycles_count,
+ const char *cumul_str)
+{
+ double predicted_percent = 0.0;
+ double abort_percent = 0.0;
+ u64 cycles = 0;
+
+ if (branch_count == 0) {
+ if (fp)
+ return fprintf(fp, " (calltrace)");
+
+ return scnprintf(bf, bfsize, " (calltrace)");
+ }
+
+ predicted_percent = predicted_count * 100.0 / branch_count;
+ abort_percent = abort_count * 100.0 / branch_count;
+ cycles = cycles_count / branch_count;
+
+ if ((predicted_percent >= 100.0) && (abort_percent <= 0.0)) {
+ if (fp)
+ return fprintf(fp, " (%scycles:%" PRId64 ")",
+ cumul_str, cycles);
+
+ return scnprintf(bf, bfsize, " (%scycles:%" PRId64 ")",
+ cumul_str, cycles);
+ }
+
+ if ((predicted_percent < 100.0) && (abort_percent <= 0.0)) {
+ if (fp)
+ return fprintf(fp,
+ " (%spredicted:%.1f%%, cycles:%" PRId64 ")",
+ cumul_str, predicted_percent, cycles);
+
+ return scnprintf(bf, bfsize,
+ " (%spredicted:%.1f%%, cycles:%" PRId64 ")",
+ cumul_str, predicted_percent, cycles);
+ }
+
+ if (fp)
+ return fprintf(fp,
+ " (%spredicted:%.1f%%, abort:%.1f%%, cycles:%" PRId64 ")",
+ cumul_str, predicted_percent, abort_percent, cycles);
+
+ return scnprintf(bf, bfsize,
+ " (%spredicted:%.1f%%, abort:%.1f%%, cycles:%" PRId64 ")",
+ cumul_str, predicted_percent, abort_percent, cycles);
+}
+
+int callchain_list_counts__printf_value(struct callchain_list *clist,
+ FILE *fp, char *bf, int bfsize)
+{
+ u64 branch_count, predicted_count;
+ u64 abort_count, cycles_count;
+
+ branch_count = clist->branch_count;
+ predicted_count = clist->predicted_count;
+ abort_count = clist->abort_count;
+ cycles_count = clist->cycles_count;
+
+ return callchain_counts_printf(fp, bf, bfsize, branch_count,
+ predicted_count, abort_count,
+ cycles_count, "");
+}
+
static void free_callchain_node(struct callchain_node *node)
{
struct callchain_list *list, *tmp;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 40ecf25..4f6bf6c 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -115,6 +115,10 @@ struct callchain_list {
bool unfolded;
bool has_children;
};
+ u64 branch_count;
+ u64 predicted_count;
+ u64 abort_count;
+ u64 cycles_count;
char *srcline;
struct list_head list;
};
@@ -264,8 +268,15 @@ char *callchain_node__scnprintf_value(struct callchain_node *node,
int callchain_node__fprintf_value(struct callchain_node *node,
FILE *fp, u64 total);
+int callchain_list_counts__printf_value(struct callchain_list *clist,
+ FILE *fp, char *bf, int bfsize);
+
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);
+
#endif /* __PERF_CALLCHAIN_H */
--
2.7.4
[toc] | [next] | [standalone]
| From | Nilay Vaish <nilayvaish@gmail.com> |
|---|---|
| Date | 2016-10-20 18:50 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <suoHv-1G4-5@gated-at.bofh.it> |
| In reply to | #1504097 |
On 19 October 2016 at 17:01, Jin Yao <yao.jin@linux.intel.com> wrote:
> diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
> index 40ecf25..4f6bf6c 100644
> --- a/tools/perf/util/callchain.h
> +++ b/tools/perf/util/callchain.h
> @@ -115,6 +115,10 @@ struct callchain_list {
> bool unfolded;
> bool has_children;
> };
> + u64 branch_count;
> + u64 predicted_count;
> + u64 abort_count;
Can you explain what abort count is? It seems you are referring to
miss-speculated branches. If that is the case, I would prefer that we
replace abort by miss_speculated or miss_predicted.
--
Nilay
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <ak@linux.intel.com> |
|---|---|
| Date | 2016-10-20 18:50 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <suoHw-1G4-15@gated-at.bofh.it> |
| In reply to | #1505094 |
On Thu, Oct 20, 2016 at 11:41:11AM -0500, Nilay Vaish wrote:
> On 19 October 2016 at 17:01, Jin Yao <yao.jin@linux.intel.com> wrote:
> > diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
> > index 40ecf25..4f6bf6c 100644
> > --- a/tools/perf/util/callchain.h
> > +++ b/tools/perf/util/callchain.h
> > @@ -115,6 +115,10 @@ struct callchain_list {
> > bool unfolded;
> > bool has_children;
> > };
> > + u64 branch_count;
> > + u64 predicted_count;
> > + u64 abort_count;
>
> Can you explain what abort count is? It seems you are referring to
> miss-speculated branches. If that is the case, I would prefer that we
> replace abort by miss_speculated or miss_predicted.
abort refers to TSX aborts. It has nothing to do with branch
mispredictions.
-Andi
[toc] | [prev] | [next] | [standalone]
| From | Nilay Vaish <nilayvaish@gmail.com> |
|---|---|
| Date | 2016-10-20 19:10 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <sup0R-21Y-17@gated-at.bofh.it> |
| In reply to | #1505097 |
On 20 October 2016 at 11:48, Andi Kleen <ak@linux.intel.com> wrote:
> On Thu, Oct 20, 2016 at 11:41:11AM -0500, Nilay Vaish wrote:
>> On 19 October 2016 at 17:01, Jin Yao <yao.jin@linux.intel.com> wrote:
>> > diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
>> > index 40ecf25..4f6bf6c 100644
>> > --- a/tools/perf/util/callchain.h
>> > +++ b/tools/perf/util/callchain.h
>> > @@ -115,6 +115,10 @@ struct callchain_list {
>> > bool unfolded;
>> > bool has_children;
>> > };
>> > + u64 branch_count;
>> > + u64 predicted_count;
>> > + u64 abort_count;
>>
>> Can you explain what abort count is? It seems you are referring to
>> miss-speculated branches. If that is the case, I would prefer that we
>> replace abort by miss_speculated or miss_predicted.
>
> abort refers to TSX aborts. It has nothing to do with branch
> mispredictions.
OK, I am more confused now. Are you predicting some quantity related
to transactions? Why would you divide abort count by branch count?
Further, I just looked at patch 6/6. It has the following text:
+ Also show with some branch flags that can be:
+ - Predicted: display the average percentage of predicated branches.
+ (predicated number / total number)
+ - Abort: display the average percentage of abort branches.
+ (abort number /total number)
+ - Cycles: cycles in basic block.
I think there is inconsistency between what you are suggesting and
what the patch has.
--
Nilay
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <ak@linux.intel.com> |
|---|---|
| Date | 2016-10-20 20:30 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <suqgi-2Md-25@gated-at.bofh.it> |
| In reply to | #1505103 |
> OK, I am more confused now. Are you predicting some quantity related > to transactions? Why would you divide abort count by branch count? > Further, I just looked at patch 6/6. It has the following text: > > + Also show with some branch flags that can be: > + - Predicted: display the average percentage of predicated branches. > + (predicated number / total number) > + - Abort: display the average percentage of abort branches. > + (abort number /total number) > + - Cycles: cycles in basic block. > > > I think there is inconsistency between what you are suggesting and > what the patch has. An abort is an unique branch. But yes there is no total number, so the formula will always be 100%. So yes would probably be better to just display a count for abort. -Andi
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2016-10-21 02:30 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <suvSF-6p0-7@gated-at.bofh.it> |
| In reply to | #1505174 |
Hi Andi, Hi Nilay, Thanks so much for your comments! I will upgrade the patch to just display the count for abort. Thanks Jin Yao On 10/21/2016 2:20 AM, Andi Kleen wrote: >> OK, I am more confused now. Are you predicting some quantity related >> to transactions? Why would you divide abort count by branch count? >> Further, I just looked at patch 6/6. It has the following text: >> >> + Also show with some branch flags that can be: >> + - Predicted: display the average percentage of predicated branches. >> + (predicated number / total number) >> + - Abort: display the average percentage of abort branches. >> + (abort number /total number) >> + - Cycles: cycles in basic block. >> >> >> I think there is inconsistency between what you are suggesting and >> what the patch has. > An abort is an unique branch. But yes there is no total number, > so the formula will always be 100%. So yes would probably be > better to just display a count for abort. > > -Andi
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-10-25 20:20 +0200 |
| Subject | Re: [PATCH v2 2/6] perf report: Caculate and return the branch counting in callchain |
| Message-ID | <sweul-Lo-21@gated-at.bofh.it> |
| In reply to | #1505351 |
Em Fri, Oct 21, 2016 at 08:23:41AM +0800, Jin, Yao escreveu: > Hi Andi, Hi Nilay, > > Thanks so much for your comments! > > I will upgrade the patch to just display the count for abort. Ok, waiting for that then, - Arnaldo > Thanks > > Jin Yao > > On 10/21/2016 2:20 AM, Andi Kleen wrote: > > > OK, I am more confused now. Are you predicting some quantity related > > > to transactions? Why would you divide abort count by branch count? > > > Further, I just looked at patch 6/6. It has the following text: > > > > > > + Also show with some branch flags that can be: > > > + - Predicted: display the average percentage of predicated branches. > > > + (predicated number / total number) > > > + - Abort: display the average percentage of abort branches. > > > + (abort number /total number) > > > + - Cycles: cycles in basic block. > > > > > > > > > I think there is inconsistency between what you are suggesting and > > > what the patch has. > > An abort is an unique branch. But yes there is no total number, > > so the formula will always be 100%. So yes would probably be > > better to just display a count for abort. > > > > -Andi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web