perf stat record: Save cache level information
authorK Prateek Nayak <kprateek.nayak@amd.com>
Wed, 17 May 2023 17:27:43 +0000 (22:57 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 23 May 2023 19:10:13 +0000 (16:10 -0300)
When aggregating based on cache-topology, in addition to the aggregation
mode, knowing the cache level at which data is aggregated is necessary
to ensure consistency when running 'perf stat record' and later 'perf
stat report'.

Save the cache level for aggregation as a part of the env data that can
be later retrieved when running perf stat report.

Suggested-by: Gautham Shenoy <gautham.shenoy@amd.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wen Pu <puwen@hygon.cn>
Link: https://lore.kernel.org/r/20230517172745.5833-4-kprateek.nayak@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/perf/include/perf/event.h
tools/perf/util/event.c
tools/perf/util/synthetic-events.c

index 51b9338..ba2dcf6 100644 (file)
@@ -380,7 +380,8 @@ enum {
        PERF_STAT_CONFIG_TERM__AGGR_MODE        = 0,
        PERF_STAT_CONFIG_TERM__INTERVAL         = 1,
        PERF_STAT_CONFIG_TERM__SCALE            = 2,
-       PERF_STAT_CONFIG_TERM__MAX              = 3,
+       PERF_STAT_CONFIG_TERM__AGGR_LEVEL       = 3,
+       PERF_STAT_CONFIG_TERM__MAX              = 4,
 };
 
 struct perf_record_stat_config_entry {
index 8ae742e..e8b0666 100644 (file)
@@ -135,9 +135,10 @@ void perf_event__read_stat_config(struct perf_stat_config *config,
                        config->__val = event->data[i].val;     \
                        break;
 
-               CASE(AGGR_MODE, aggr_mode)
-               CASE(SCALE,     scale)
-               CASE(INTERVAL,  interval)
+               CASE(AGGR_MODE,  aggr_mode)
+               CASE(SCALE,      scale)
+               CASE(INTERVAL,   interval)
+               CASE(AGGR_LEVEL, aggr_level)
 #undef CASE
                default:
                        pr_warning("unknown stat config term %" PRI_lu64 "\n",
index b2e4afa..45714a2 100644 (file)
@@ -1375,6 +1375,7 @@ int perf_event__synthesize_stat_config(struct perf_tool *tool,
        ADD(AGGR_MODE,  config->aggr_mode)
        ADD(INTERVAL,   config->interval)
        ADD(SCALE,      config->scale)
+       ADD(AGGR_LEVEL, config->aggr_level)
 
        WARN_ONCE(i != PERF_STAT_CONFIG_TERM__MAX,
                  "stat config terms unbalanced\n");