From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753247AbbKCKyH (ORCPT ); Tue, 3 Nov 2015 05:54:07 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:36406 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752102AbbKCKyD (ORCPT ); Tue, 3 Nov 2015 05:54:03 -0500 Date: Tue, 3 Nov 2015 19:53:51 +0900 From: Namhyung Kim To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , Brendan Gregg , David Ahern , Frederic Weisbecker , Andi Kleen , Kan Liang Subject: Re: [PATCH v3 4/4] perf report: Add callchain value option Message-ID: <20151103105351.GB5733@danjae.kornet> References: <1446535111-31713-1-git-send-email-namhyung@kernel.org> <1446535111-31713-5-git-send-email-namhyung@kernel.org> <20151103090627.GC31745@krava.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151103090627.GC31745@krava.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2015 at 10:06:27AM +0100, Jiri Olsa wrote: > On Tue, Nov 03, 2015 at 04:18:31PM +0900, Namhyung Kim wrote: > > SNIP > > > @@ -819,12 +837,26 @@ 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); > > + u64 period = callchain_cumul_hits(node); > > + int count = callchain_cumul_counts(node); > > > > if (total) > > - percent = cumul * 100.0 / total; > > + percent = period * 100.0 / total; > > + if (callchain_param.mode == CHAIN_FOLDED) > > + count = node->count; > > this could be set/computed below in respective cases As you said, I need to check it for node->hit too. So I ended up having like following, does it look good to you? double percent = 0.0; u64 period = callchain_cumul_hits(node); unsigned count = callchain_cumul_counts(node); if (callchain_param.mode == CHAIN_FOLDED) { period = node->hit; count = node->count; } switch (callchain_param.value) { case CCVAL_PERIOD: scnprintf(bf, bfsize, "%"PRIu64, period); break; case CCVAL_COUNT: scnprintf(bf, bfsize, "%u", count); break; case CCVAL_PERCENT: default: if (total) percent = period * 100.0 / total; scnprintf(bf, bfsize, "%.2f%%", percent); break; } return bf; Thanks, Namhyung > > > > > - scnprintf(bf, bfsize, "%6.2f%%", percent); > > + switch (callchain_param.value) { > > + case CCVAL_PERIOD: > > + scnprintf(bf, bfsize, "%"PRIu64, period); > > + break; > > + case CCVAL_COUNT: > > + scnprintf(bf, bfsize, "%u", count); > > + break; > > + case CCVAL_PERCENT: > > + default: > > + scnprintf(bf, bfsize, "%.2f%%", percent); > > + break; > > + } > > return bf; > > } > > > > @@ -832,12 +864,24 @@ int callchain_node__fprintf_value(struct callchain_node *node, > > FILE *fp, u64 total) > > { > > double percent = 0.0; > > - u64 cumul = callchain_cumul_hits(node); > > + u64 period = callchain_cumul_hits(node); > > + int count = callchain_cumul_counts(node); > > > > if (total) > > - percent = cumul * 100.0 / total; > > - > > - return percent_color_fprintf(fp, "%.2f%%", percent); > > + percent = period * 100.0 / total; > > + if (callchain_param.mode == CHAIN_FOLDED) > > + count = node->count; > > + > > ditto > > jirka > > > + switch (callchain_param.value) { > > + case CCVAL_PERIOD: > > + return fprintf(fp, "%"PRIu64, period); > > + case CCVAL_COUNT: > > + return fprintf(fp, "%u", count); > > + case CCVAL_PERCENT: > > + default: > > + return percent_color_fprintf(fp, "%.2f%%", percent); > > + } > > + return 0; > > } > > > > SNIP