From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
LKML <linux-kernel@vger.kernel.org>,
Brendan Gregg <brendan.d.gregg@gmail.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Andi Kleen <andi@firstfloor.org>, Kan Liang <kan.liang@intel.com>
Subject: Re: [PATCH v3 2/4] perf callchain: Abstract callchain print function
Date: Tue, 3 Nov 2015 09:40:55 +0100 [thread overview]
Message-ID: <20151103084055.GH23878@krava.brq.redhat.com> (raw)
In-Reply-To: <1446535111-31713-3-git-send-email-namhyung@kernel.org>
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..
jirka
> 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
next prev parent reply other threads:[~2015-11-03 8:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 7:18 [PATCH 0/4] perf report: Support folded callchain output (v3) Namhyung Kim
2015-11-03 7:18 ` [PATCH v3 1/4] perf report: Support folded callchain mode on --stdio Namhyung Kim
2015-11-03 8:21 ` Jiri Olsa
2015-11-03 7:18 ` [PATCH v3 2/4] perf callchain: Abstract callchain print function Namhyung Kim
2015-11-03 8:40 ` Jiri Olsa [this message]
2015-11-03 10:31 ` Namhyung Kim
2015-11-03 7:18 ` [PATCH v3 3/4] perf callchain: Add count fields to struct callchain_node Namhyung Kim
2015-11-03 9:03 ` Jiri Olsa
2015-11-03 7:18 ` [PATCH v3 4/4] perf report: Add callchain value option Namhyung Kim
2015-11-03 9:04 ` Jiri Olsa
2015-11-03 9:06 ` Jiri Olsa
2015-11-03 10:53 ` Namhyung Kim
2015-11-03 11:19 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151103084055.GH23878@krava.brq.redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=brendan.d.gregg@gmail.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox