Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1611113 > unrolled thread

Re: [PATCH v1] perf report: Drop cycles 0 for LBR print

Started byArnaldo Carvalho de Melo <acme@kernel.org>
First post2017-03-28 17:40 +0200
Last post2017-03-28 21:40 +0200
Articles 3 — 2 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.


Contents

  Re: [PATCH v1] perf report: Drop cycles 0 for LBR print Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-03-28 17:40 +0200
    Re: [PATCH v1] perf report: Drop cycles 0 for LBR print Andi Kleen <ak@linux.intel.com> - 2017-03-28 19:10 +0200
      Re: [PATCH v1] perf report: Drop cycles 0 for LBR print Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-03-28 21:40 +0200

#1611113 — Re: [PATCH v1] perf report: Drop cycles 0 for LBR print

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-03-28 17:40 +0200
SubjectRe: [PATCH v1] perf report: Drop cycles 0 for LBR print
Message-ID<tq1nY-1do-25@gated-at.bofh.it>
Em Thu, Mar 09, 2017 at 04:06:26PM +0800, Jin Yao escreveu:
> For some platforms, for example Broadwell, it doesn't support cycles
> for LBR. But the perf always prints cycles:0, it's not necessary.
> 
> The patch refactors the LBR info print code and drops the cycles:0.
> 
> For example: perf report --branch-history --no-children --stdio

Can I get some reviewed-by or acked-by for this patch? Andi? Kan?

- Arnaldo
 
> On Broadwell:
> --0.91%--__random_r random_r.c:394 (iterations:2)
>           __random_r random_r.c:360 (predicted:0.0%)
>           __random_r random_r.c:380 (predicted:0.0%)
>           __random_r random_r.c:357
> 
> On Skylake:
> --1.07%--main div.c:39 (predicted:52.4% cycles:1 iterations:17)
>           main div.c:44 (predicted:52.4% cycles:1)
>           main div.c:42 (cycles:2)
>           compute_flag div.c:28 (cycles:2)
>           compute_flag div.c:27 (cycles:1)
>           rand rand.c:28 (cycles:1)
>           rand rand.c:28 (cycles:1)
>           __random random.c:298 (cycles:1)
>           __random random.c:297 (cycles:1)
>           __random random.c:295 (cycles:1)
>           __random random.c:295 (cycles:1)
>           __random random.c:295 (cycles:1)
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  tools/perf/util/callchain.c | 111 +++++++++++++++++++++++++++++---------------
>  1 file changed, 74 insertions(+), 37 deletions(-)
> 
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index aba9534..f84626d 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -1063,63 +1063,100 @@ int callchain_branch_counts(struct callchain_root *root,
>  						  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,
> -				   u64 iter_count, u64 samples_count)
> +static int counts_str_build(char *bf, int bfsize,
> +			     u64 branch_count, u64 predicted_count,
> +			     u64 abort_count, u64 cycles_count,
> +			     u64 iter_count, u64 samples_count)
>  {
>  	double predicted_percent = 0.0;
>  	const char *null_str = "";
>  	char iter_str[32];
> -	char *str;
> -	u64 cycles = 0;
> -
> -	if (branch_count == 0) {
> -		if (fp)
> -			return fprintf(fp, " (calltrace)");
> +	char cycle_str[32];
> +	char *istr, *cstr;
> +	u64 cycles;
>  
> +	if (branch_count == 0)
>  		return scnprintf(bf, bfsize, " (calltrace)");
> -	}
> +
> +	cycles = cycles_count / branch_count;
>  
>  	if (iter_count && samples_count) {
> -		scnprintf(iter_str, sizeof(iter_str),
> -			 ", iterations:%" PRId64 "",
> -			 iter_count / samples_count);
> -		str = iter_str;
> +		if (cycles > 0)
> +			scnprintf(iter_str, sizeof(iter_str),
> +				 " iterations:%" PRId64 "",
> +				 iter_count / samples_count);
> +		else
> +			scnprintf(iter_str, sizeof(iter_str),
> +				 "iterations:%" PRId64 "",
> +				 iter_count / samples_count);
> +		istr = iter_str;
> +	} else
> +		istr = (char *)null_str;
> +
> +	if (cycles > 0) {
> +		scnprintf(cycle_str, sizeof(cycle_str),
> +			  "cycles:%" PRId64 "", cycles);
> +		cstr = cycle_str;
>  	} else
> -		str = (char *)null_str;
> +		cstr = (char *)null_str;
>  
>  	predicted_percent = predicted_count * 100.0 / branch_count;
> -	cycles = cycles_count / branch_count;
>  
> -	if ((predicted_percent >= 100.0) && (abort_count == 0)) {
> -		if (fp)
> -			return fprintf(fp, " (cycles:%" PRId64 "%s)",
> -				       cycles, str);
> +	if ((predicted_count == branch_count) && (abort_count == 0)) {
> +		if ((cycles > 0) || (istr != (char *)null_str))
> +			return scnprintf(bf, bfsize, " (%s%s)", cstr, istr);
> +		else
> +			return scnprintf(bf, bfsize, "%s", (char *)null_str);
> +	}
>  
> -		return scnprintf(bf, bfsize, " (cycles:%" PRId64 "%s)",
> -				 cycles, str);
> +	if ((predicted_count < branch_count) && (abort_count == 0)) {
> +		if ((cycles > 0) || (istr != (char *)null_str))
> +			return scnprintf(bf, bfsize,
> +				" (predicted:%.1f%% %s%s)",
> +				predicted_percent, cstr, istr);
> +		else {
> +			return scnprintf(bf, bfsize,
> +				" (predicted:%.1f%%)",
> +				predicted_percent);
> +		}
>  	}
>  
> -	if ((predicted_percent < 100.0) && (abort_count == 0)) {
> -		if (fp)
> -			return fprintf(fp,
> -				" (predicted:%.1f%%, cycles:%" PRId64 "%s)",
> -				predicted_percent, cycles, str);
> +	if ((predicted_count == branch_count) && (abort_count > 0)) {
> +		if ((cycles > 0) || (istr != (char *)null_str))
> +			return scnprintf(bf, bfsize,
> +				" (abort:%" PRId64 " %s%s)",
> +				abort_count, cstr, istr);
> +		else
> +			return scnprintf(bf, bfsize,
> +				" (abort:%" PRId64 ")",
> +				abort_count);
> +	}
>  
> +	if ((cycles > 0) || (istr != (char *)null_str))
>  		return scnprintf(bf, bfsize,
> -			" (predicted:%.1f%%, cycles:%" PRId64 "%s)",
> -			predicted_percent, cycles, str);
> -	}
> +			" (predicted:%.1f%% abort:%" PRId64 " %s%s)",
> +			predicted_percent, abort_count, cstr, istr);
> +
> +	return scnprintf(bf, bfsize,
> +			" (predicted:%.1f%% abort:%" PRId64 ")",
> +			predicted_percent, abort_count);
> +}
> +
> +static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
> +				   u64 branch_count, u64 predicted_count,
> +				   u64 abort_count, u64 cycles_count,
> +				   u64 iter_count, u64 samples_count)
> +{
> +	char str[128];
> +
> +	counts_str_build(str, sizeof(str), branch_count,
> +			 predicted_count, abort_count, cycles_count,
> +			 iter_count, samples_count);
>  
>  	if (fp)
> -		return fprintf(fp,
> -		" (predicted:%.1f%%, abort:%" PRId64 ", cycles:%" PRId64 "%s)",
> -			predicted_percent, abort_count, cycles, str);
> +		return fprintf(fp, "%s", str);
>  
> -	return scnprintf(bf, bfsize,
> -		" (predicted:%.1f%%, abort:%" PRId64 ", cycles:%" PRId64 "%s)",
> -		predicted_percent, abort_count, cycles, str);
> +	return scnprintf(bf, bfsize, "%s", str);
>  }
>  
>  int callchain_list_counts__printf_value(struct callchain_node *node,
> -- 
> 2.7.4

[toc] | [next] | [standalone]


#1611229

FromAndi Kleen <ak@linux.intel.com>
Date2017-03-28 19:10 +0200
Message-ID<tq2N5-2mE-25@gated-at.bofh.it>
In reply to#1611113
On Tue, Mar 28, 2017 at 12:34:52PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Mar 09, 2017 at 04:06:26PM +0800, Jin Yao escreveu:
> > For some platforms, for example Broadwell, it doesn't support cycles
> > for LBR. But the perf always prints cycles:0, it's not necessary.
> > 
> > The patch refactors the LBR info print code and drops the cycles:0.
> > 
> > For example: perf report --branch-history --no-children --stdio
> 
> Can I get some reviewed-by or acked-by for this patch? Andi? Kan?

Reviewed-by: Andi Kleen <ak@linux.intel.com>

-Andi

[toc] | [prev] | [next] | [standalone]


#1611319

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-03-28 21:40 +0200
Message-ID<tq58f-3Wt-59@gated-at.bofh.it>
In reply to#1611229
Em Tue, Mar 28, 2017 at 10:05:44AM -0700, Andi Kleen escreveu:
> On Tue, Mar 28, 2017 at 12:34:52PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Mar 09, 2017 at 04:06:26PM +0800, Jin Yao escreveu:
> > > For some platforms, for example Broadwell, it doesn't support cycles
> > > for LBR. But the perf always prints cycles:0, it's not necessary.
> > > 
> > > The patch refactors the LBR info print code and drops the cycles:0.
> > > 
> > > For example: perf report --branch-history --no-children --stdio
> > 
> > Can I get some reviewed-by or acked-by for this patch? Andi? Kan?
> 
> Reviewed-by: Andi Kleen <ak@linux.intel.com>

Thanks, applied.

- Arnaldo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web