From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756515AbdJLLaX (ORCPT ); Thu, 12 Oct 2017 07:30:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57816 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754802AbdJLLaW (ORCPT ); Thu, 12 Oct 2017 07:30:22 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0C43D7EA95 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Thu, 12 Oct 2017 13:30:19 +0200 From: Jiri Olsa To: Jin Yao Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com Subject: Re: [PATCH] perf stat: Support metrics with perf stat --per-thread Message-ID: <20171012113019.GA4872@krava> References: <1507799100-2667-1-git-send-email-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1507799100-2667-1-git-send-email-yao.jin@linux.intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 12 Oct 2017 11:30:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 12, 2017 at 05:05:00PM +0800, Jin Yao wrote: SNIP > Signed-off-by: Jin Yao > --- > tools/perf/util/stat.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c > index 35e9848..1164e68 100644 > --- a/tools/perf/util/stat.c > +++ b/tools/perf/util/stat.c > @@ -314,6 +314,26 @@ static int process_counter_maps(struct perf_stat_config *config, > return 0; > } > > +static int process_aggr_thread_counter(struct perf_evsel *counter) > +{ > + int nthreads = thread_map__nr(counter->threads); > + int ncpus = cpu_map__nr(counter->cpus); > + int cpu, thread; > + u64 tmp; > + > + for (thread = 0; thread < nthreads; thread++) { > + u64 val = 0; > + > + for (cpu = 0; cpu < ncpus; cpu++) > + val += perf_counts(counter->counts, cpu, thread)->val; > + > + tmp = val * counter->scale; > + perf_stat__update_shadow_stats(counter, &tmp, 0); > + } > + > + return 0; > +} > + > int perf_stat_process_counter(struct perf_stat_config *config, > struct perf_evsel *counter) > { > @@ -342,6 +362,9 @@ int perf_stat_process_counter(struct perf_stat_config *config, > if (ret) > return ret; > > + if (config->aggr_mode == AGGR_THREAD) > + return process_aggr_thread_counter(counter); > + > if (config->aggr_mode != AGGR_GLOBAL) > return 0; > > -- > 2.7.4 > I wonder if patch below would be enough for this jirka --- diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 35e9848734d6..56a0a36d0653 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -259,6 +259,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel struct perf_counts_values *aggr = &evsel->counts->aggr; static struct perf_counts_values zero; bool skip = false; + u64 val; if (check_per_pkg(evsel, count, cpu, &skip)) { pr_err("failed to read per-pkg counter\n"); @@ -270,6 +271,9 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel switch (config->aggr_mode) { case AGGR_THREAD: + val = count->val * evsel->scale; + perf_stat__update_shadow_stats(evsel, &val, 0); + break; case AGGR_CORE: case AGGR_SOCKET: case AGGR_NONE: