From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934341AbbHKNZi (ORCPT ); Tue, 11 Aug 2015 09:25:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44016 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934066AbbHKNZh (ORCPT ); Tue, 11 Aug 2015 09:25:37 -0400 Date: Tue, 11 Aug 2015 15:25:32 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com, namhyung@kernel.org, peterz@infradead.org, mingo@kernel.org, Andi Kleen Subject: Re: [PATCH 2/9] perf, tools, stat: Support up-scaling of events Message-ID: <20150811132532.GB1942@krava.brq.redhat.com> References: <1438995985-13631-1-git-send-email-andi@firstfloor.org> <1438995985-13631-3-git-send-email-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438995985-13631-3-git-send-email-andi@firstfloor.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 07, 2015 at 06:06:18PM -0700, Andi Kleen wrote: > From: Andi Kleen > > TopDown needs to multiply events by constants (for example > the CPU Pipeline Width) to get the correct results. > The kernel needs to export this factor. > > Today *.scale is only used to scale down metrics (divide), for example > to scale bytes to MB. > > Repurpose negative scale to mean scaling up, that is multiplying. > Implement the code for this in perf stat. > > Signed-off-by: Andi Kleen > --- > tools/perf/builtin-stat.c | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index ea5298a..2590c75 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -179,6 +179,17 @@ static inline int nsec_counter(struct perf_evsel *evsel) > return 0; > } > > +static double scale_val(struct perf_evsel *counter, u64 val) > +{ > + double uval = val; > + > + if (counter->scale < 0) > + uval = val * (-counter->scale); > + else if (counter->scale) > + uval = val / counter->scale; hum, do you change the scale logic? the current scale > 0 works like: uval = val * counter->scale; jirka