Commit 1fa0c371 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf pmu-events: Change aggr_mode to be an enum

Rather than use a string to encode aggr_mode, use an enum value.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Link: https://lore.kernel.org/r/20230219092848.639226-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 36d19bbb
...@@ -45,6 +45,6 @@ int arch_get_runtimeparam(const struct pmu_metric *pm) ...@@ -45,6 +45,6 @@ int arch_get_runtimeparam(const struct pmu_metric *pm)
int count; int count;
char path[PATH_MAX] = "/devices/hv_24x7/interface/"; char path[PATH_MAX] = "/devices/hv_24x7/interface/";
atoi(pm->aggr_mode) == PerChip ? strcat(path, "sockets") : strcat(path, "coresperchip"); strcat(path, pm->aggr_mode == PerChip ? "sockets" : "coresperchip");
return sysfs__read_int(path, &count) < 0 ? 1 : count; return sysfs__read_int(path, &count) < 0 ? 1 : count;
} }
...@@ -678,10 +678,13 @@ static void decompress_event(int offset, struct pmu_event *pe) ...@@ -678,10 +678,13 @@ static void decompress_event(int offset, struct pmu_event *pe)
{ {
\tconst char *p = &big_c_string[offset]; \tconst char *p = &big_c_string[offset];
""") """)
enum_attributes = ['aggr_mode']
for attr in _json_event_attributes: for attr in _json_event_attributes:
_args.output_file.write(f""" _args.output_file.write(f'\n\tpe->{attr} = ')
\tpe->{attr} = (*p == '\\0' ? NULL : p); if attr in enum_attributes:
""") _args.output_file.write("(*p == '\\0' ? 0 : *p - '0');\n")
else:
_args.output_file.write("(*p == '\\0' ? NULL : p);\n")
if attr == _json_event_attributes[-1]: if attr == _json_event_attributes[-1]:
continue continue
_args.output_file.write('\twhile (*p++);') _args.output_file.write('\twhile (*p++);')
...@@ -692,9 +695,11 @@ static void decompress_metric(int offset, struct pmu_metric *pm) ...@@ -692,9 +695,11 @@ static void decompress_metric(int offset, struct pmu_metric *pm)
\tconst char *p = &big_c_string[offset]; \tconst char *p = &big_c_string[offset];
""") """)
for attr in _json_metric_attributes: for attr in _json_metric_attributes:
_args.output_file.write(f""" _args.output_file.write(f'\n\tpm->{attr} = ')
\tpm->{attr} = (*p == '\\0' ? NULL : p); if attr in enum_attributes:
""") _args.output_file.write("(*p == '\\0' ? 0 : *p - '0');\n")
else:
_args.output_file.write("(*p == '\\0' ? NULL : p);\n")
if attr == _json_metric_attributes[-1]: if attr == _json_metric_attributes[-1]:
continue continue
_args.output_file.write('\twhile (*p++);') _args.output_file.write('\twhile (*p++);')
......
...@@ -31,10 +31,10 @@ struct pmu_metric { ...@@ -31,10 +31,10 @@ struct pmu_metric {
const char *metric_expr; const char *metric_expr;
const char *unit; const char *unit;
const char *compat; const char *compat;
const char *aggr_mode;
const char *metric_constraint; const char *metric_constraint;
const char *desc; const char *desc;
const char *long_desc; const char *long_desc;
enum aggr_mode_class aggr_mode;
}; };
struct pmu_events_table; struct pmu_events_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment