Re: [PATCH v1 5/5] perf, tools, script: Allow computing metrics in perf script

From: Jiri Olsa
Date: Mon Nov 13 2017 - 04:30:18 EST


On Thu, Nov 09, 2017 at 06:55:28AM -0800, Andi Kleen wrote:

SNIP

> static void process_event(struct perf_script *script,
> struct perf_sample *sample, struct perf_evsel *evsel,
> struct addr_location *al,
> @@ -1481,6 +1560,9 @@ static void process_event(struct perf_script *script,
> if (PRINT_FIELD(PHYS_ADDR))
> printf("%16" PRIx64, sample->phys_addr);
> printf("\n");
> +
> + if (PRINT_FIELD(METRIC))
> + print_metric(script, thread, evsel, sample);
> }
>
> static struct scripting_ops *scripting_ops;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 25f21cde8826..27a72b883645 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -108,6 +108,8 @@ struct perf_evsel {
> struct cpu_map *cpus;
> struct cpu_map *own_cpus;
> struct thread_map *threads;
> + u64 val;
> + int gnum;

please put this to the priv (struct perf_stat_evsel)
with some comments that it's used in script only

also there's per event dump feature that uses evsel->priv
(please rebase to latest Arnaldo's perf/core) in script,
so make sure you are mutualy exclusive

thanks,
jirka