From: Jiri Olsa <jolsa@redhat.com>
To: Jin Yao <yao.jin@linux.intel.com>
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
Date: Thu, 12 Oct 2017 13:30:19 +0200 [thread overview]
Message-ID: <20171012113019.GA4872@krava> (raw)
In-Reply-To: <1507799100-2667-1-git-send-email-yao.jin@linux.intel.com>
On Thu, Oct 12, 2017 at 05:05:00PM +0800, Jin Yao wrote:
SNIP
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
> 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:
next prev parent reply other threads:[~2017-10-12 11:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 9:05 [PATCH] perf stat: Support metrics with perf stat --per-thread Jin Yao
2017-10-12 11:30 ` Jiri Olsa [this message]
2017-10-12 12:13 ` Jin, Yao
2017-10-12 13:06 ` Jiri Olsa
2017-10-12 13:09 ` Jin, Yao
2017-10-12 11:30 ` 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=20171012113019.GA4872@krava \
--to=jolsa@redhat.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
--cc=yao.jin@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.