Skip to content

Commit eeb6b12

Browse files
captain5050acmel
authored andcommitted
perf jevents: Don't append Unit to desc
Unit with the PMU name is appended to desc in jevents.py, but on hybrid platforms it causes the desc to differ from the regular non-hybrid system with a PMU of 'cpu'. Having differing descs means the events don't deduplicate. To make the perf list output not differ, append the Unit on again in the perf list printing code. On x86 reduces the binary size by 409,600 bytes or about 4%. Update pmu-events test expectations to match the differently generated pmu-events.c code. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Gaosheng Cui <cuigaosheng1@huawei.com> 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: 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: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230824183212.374787-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f208b2c commit eeb6b12

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

tools/perf/builtin-list.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,20 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
145145
putchar('\n');
146146

147147
if (desc && print_state->desc) {
148+
char *desc_with_unit = NULL;
149+
int desc_len = -1;
150+
151+
if (pmu_name && strcmp(pmu_name, "cpu")) {
152+
desc_len = strlen(desc);
153+
desc_len = asprintf(&desc_with_unit,
154+
desc[desc_len - 1] != '.'
155+
? "%s. Unit: %s" : "%s Unit: %s",
156+
desc, pmu_name);
157+
}
148158
printf("%*s", 8, "[");
149-
wordwrap(desc, 8, pager_get_columns(), 0);
159+
wordwrap(desc_len > 0 ? desc_with_unit : desc, 8, pager_get_columns(), 0);
150160
printf("]\n");
161+
free(desc_with_unit);
151162
}
152163
long_desc = long_desc ?: desc;
153164
if (long_desc && print_state->long_desc) {

tools/perf/pmu-events/jevents.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,6 @@ def unit_to_pmu(unit: str) -> Optional[str]:
357357
self.desc += extra_desc
358358
if self.long_desc and extra_desc:
359359
self.long_desc += extra_desc
360-
if self.pmu and self.pmu != 'cpu':
361-
if not self.desc:
362-
self.desc = 'Unit: ' + self.pmu
363-
else:
364-
if not self.desc.endswith('. '):
365-
self.desc += '. '
366-
self.desc += 'Unit: ' + self.pmu
367360
if arch_std:
368361
if arch_std.lower() in _arch_std_events:
369362
event = _arch_std_events[arch_std.lower()].event

tools/perf/tests/pmu-events.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static const struct perf_pmu_test_event uncore_hisi_ddrc_flux_wcmd = {
129129
.event = {
130130
.name = "uncore_hisi_ddrc.flux_wcmd",
131131
.event = "event=0x2",
132-
.desc = "DDRC write commands. Unit: hisi_sccl,ddrc",
132+
.desc = "DDRC write commands",
133133
.topic = "uncore",
134134
.long_desc = "DDRC write commands",
135135
.pmu = "hisi_sccl,ddrc",
@@ -143,7 +143,7 @@ static const struct perf_pmu_test_event unc_cbo_xsnp_response_miss_eviction = {
143143
.event = {
144144
.name = "unc_cbo_xsnp_response.miss_eviction",
145145
.event = "event=0x22,umask=0x81",
146-
.desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core. Unit: uncore_cbox",
146+
.desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
147147
.topic = "uncore",
148148
.long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
149149
.pmu = "uncore_cbox",
@@ -157,7 +157,7 @@ static const struct perf_pmu_test_event uncore_hyphen = {
157157
.event = {
158158
.name = "event-hyphen",
159159
.event = "event=0xe0,umask=0x00",
160-
.desc = "UNC_CBO_HYPHEN. Unit: uncore_cbox",
160+
.desc = "UNC_CBO_HYPHEN",
161161
.topic = "uncore",
162162
.long_desc = "UNC_CBO_HYPHEN",
163163
.pmu = "uncore_cbox",
@@ -171,7 +171,7 @@ static const struct perf_pmu_test_event uncore_two_hyph = {
171171
.event = {
172172
.name = "event-two-hyph",
173173
.event = "event=0xc0,umask=0x00",
174-
.desc = "UNC_CBO_TWO_HYPH. Unit: uncore_cbox",
174+
.desc = "UNC_CBO_TWO_HYPH",
175175
.topic = "uncore",
176176
.long_desc = "UNC_CBO_TWO_HYPH",
177177
.pmu = "uncore_cbox",
@@ -185,7 +185,7 @@ static const struct perf_pmu_test_event uncore_hisi_l3c_rd_hit_cpipe = {
185185
.event = {
186186
.name = "uncore_hisi_l3c.rd_hit_cpipe",
187187
.event = "event=0x7",
188-
.desc = "Total read hits. Unit: hisi_sccl,l3c",
188+
.desc = "Total read hits",
189189
.topic = "uncore",
190190
.long_desc = "Total read hits",
191191
.pmu = "hisi_sccl,l3c",
@@ -199,7 +199,7 @@ static const struct perf_pmu_test_event uncore_imc_free_running_cache_miss = {
199199
.event = {
200200
.name = "uncore_imc_free_running.cache_miss",
201201
.event = "event=0x12",
202-
.desc = "Total cache misses. Unit: uncore_imc_free_running",
202+
.desc = "Total cache misses",
203203
.topic = "uncore",
204204
.long_desc = "Total cache misses",
205205
.pmu = "uncore_imc_free_running",
@@ -213,7 +213,7 @@ static const struct perf_pmu_test_event uncore_imc_cache_hits = {
213213
.event = {
214214
.name = "uncore_imc.cache_hits",
215215
.event = "event=0x34",
216-
.desc = "Total cache hits. Unit: uncore_imc",
216+
.desc = "Total cache hits",
217217
.topic = "uncore",
218218
.long_desc = "Total cache hits",
219219
.pmu = "uncore_imc",
@@ -238,27 +238,27 @@ static const struct perf_pmu_test_event sys_ddr_pmu_write_cycles = {
238238
.event = {
239239
.name = "sys_ddr_pmu.write_cycles",
240240
.event = "event=0x2b",
241-
.desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu",
241+
.desc = "ddr write-cycles event",
242242
.topic = "uncore",
243243
.pmu = "uncore_sys_ddr_pmu",
244244
.compat = "v8",
245245
},
246246
.alias_str = "event=0x2b",
247-
.alias_long_desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu",
247+
.alias_long_desc = "ddr write-cycles event",
248248
.matching_pmu = "uncore_sys_ddr_pmu",
249249
};
250250

251251
static const struct perf_pmu_test_event sys_ccn_pmu_read_cycles = {
252252
.event = {
253253
.name = "sys_ccn_pmu.read_cycles",
254254
.event = "config=0x2c",
255-
.desc = "ccn read-cycles event. Unit: uncore_sys_ccn_pmu",
255+
.desc = "ccn read-cycles event",
256256
.topic = "uncore",
257257
.pmu = "uncore_sys_ccn_pmu",
258258
.compat = "0x01",
259259
},
260260
.alias_str = "config=0x2c",
261-
.alias_long_desc = "ccn read-cycles event. Unit: uncore_sys_ccn_pmu",
261+
.alias_long_desc = "ccn read-cycles event",
262262
.matching_pmu = "uncore_sys_ccn_pmu",
263263
};
264264

0 commit comments

Comments
 (0)