lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151103103113.GA5733@danjae.kornet>
Date:	Tue, 3 Nov 2015 19:31:13 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Jiri Olsa <jolsa@...hat.com>
Cc:	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	LKML <linux-kernel@...r.kernel.org>,
	Brendan Gregg <brendan.d.gregg@...il.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Andi Kleen <andi@...stfloor.org>,
	Kan Liang <kan.liang@...el.com>
Subject: Re: [PATCH v3 2/4] perf callchain: Abstract callchain print function

Hi Jiri,

On Tue, Nov 03, 2015 at 09:40:55AM +0100, Jiri Olsa wrote:
> On Tue, Nov 03, 2015 at 04:18:29PM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> >  	while (rb_node) {
> > -		double percent;
> > -
> >  		chain = rb_entry(rb_node, struct callchain_node, rb_node);
> > -		percent = chain->hit * 100.0 / total_samples;
> >  
> > -		ret = percent_color_fprintf(fp, "           %6.2f%%\n", percent);
> > +		ret += fprintf(fp, "           ");
> > +		ret += callchain_node__fprintf_value(chain, fp, total_samples);
> > +		ret += fprintf(fp, "\n");
> >  		ret += __callchain__fprintf_flat(fp, chain, total_samples);
> >  		ret += fprintf(fp, "\n");
> >  		if (++entries_printed == callchain_param.print_limit)
> > @@ -294,12 +294,11 @@ static size_t callchain__fprintf_folded(FILE *fp, struct rb_root *tree,
> >  	struct rb_node *rb_node = rb_first(tree);
> >  
> >  	while (rb_node) {
> > -		double percent;
> >  
> >  		chain = rb_entry(rb_node, struct callchain_node, rb_node);
> > -		percent = chain->hit * 100.0 / total_samples;
> >  
> > -		ret += fprintf(fp, "%.2f%% ", percent);
> > +		ret += callchain_node__fprintf_value(chain, fp, total_samples);
> > +		ret += fprintf(fp, " ");
> 
> hum, the callchain_node__fprintf_value gets hits as callchain_cumul_hits(node)
> which is 'node->hit + node->children_hit'
> 
> while the replaced code took only 'chain->hit'
> 
> not sure now which one we actualy want here..

Right, this is somewhat confusing..

AFAICS cumul_hits is used for other output mode, but for folded output
we should use hit without children_hit.

I added the check to use count in patch 4/4 but missed to use hit.
Will update.

Thanks,
Namhyung



> 
> >  		ret += __callchain__fprintf_folded(fp, chain);
> >  		ret += fprintf(fp, "\n");
> >  		if (++entries_printed == callchain_param.print_limit)
> > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> > index 08cb220ba5ea..44184d198855 100644
> > --- a/tools/perf/util/callchain.c
> > +++ b/tools/perf/util/callchain.c
> > @@ -805,6 +805,31 @@ char *callchain_list__sym_name(struct callchain_list *cl,
> >  	return bf;
> >  }
> >  
> > +char *callchain_node__sprintf_value(struct callchain_node *node,
> > +				    char *bf, size_t bfsize, u64 total)
> > +{
> > +	double percent = 0.0;
> > +	u64 cumul = callchain_cumul_hits(node);
> > +
> > +	if (total)
> > +		percent = cumul * 100.0 / total;
> > +
> > +	scnprintf(bf, bfsize, "%6.2f%%", percent);
> > +	return bf;
> > +}
> > +
> > +int callchain_node__fprintf_value(struct callchain_node *node,
> > +				 FILE *fp, u64 total)
> > +{
> > +	double percent = 0.0;
> > +	u64 cumul = callchain_cumul_hits(node);
> > +
> > +	if (total)
> > +		percent = cumul * 100.0 / total;
> > +
> > +	return percent_color_fprintf(fp, "%.2f%%", percent);
> > +}
> 
> SNIP
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ