Messages in this thread Patch in this message | | | Date | Thu, 12 Oct 2017 13:30:19 +0200 | From | Jiri Olsa <> | Subject | Re: [PATCH] perf stat: Support metrics with perf stat --per-thread |
| |
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:
| |