diff options
author | Ian Rogers <irogers@google.com> | 2024-06-12 15:40:27 +0300 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2024-06-14 07:27:49 +0300 |
commit | 65b37df8c61ceea863ac0ac188fe3464c2ee3ac0 (patch) | |
tree | d36f5576949002c7d5a6e4c679d2f7382ff1be51 | |
parent | 245b0edf4838874801cd35b0507ed9ec38742e8e (diff) | |
download | linux-65b37df8c61ceea863ac0ac188fe3464c2ee3ac0.tar.xz |
perf test pmu: Warn don't fail for legacy mixed case event names
PowerPC has mixed case events matching legacy hardware cache
events. Warn but don't fail in this case. Event parsing will still
work in this case by matching the legacy case.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kajol Jain <kjain@linux.ibm.com>
Cc: James Clark <james.clark@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240612124027.2712643-1-irogers@google.com
-rw-r--r-- | tools/perf/tests/pmu.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index cc88b5920c3e..201df4446f7c 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c @@ -260,26 +260,42 @@ err_out: static bool permitted_event_name(const char *name) { bool has_lower = false, has_upper = false; + __u64 config; for (size_t i = 0; i < strlen(name); i++) { char c = name[i]; if (islower(c)) { if (has_upper) - return false; + goto check_legacy; has_lower = true; continue; } if (isupper(c)) { if (has_lower) - return false; + goto check_legacy; has_upper = true; continue; } if (!isdigit(c) && c != '.' && c != '_' && c != '-') - return false; + goto check_legacy; } return true; +check_legacy: + /* + * If the event name matches a legacy cache name the legacy encoding + * will still be used. This isn't quite WAI as sysfs events should take + * priority, but this case happens on PowerPC and matches the behavior + * in older perf tools where legacy events were the priority. Be + * permissive and assume later PMU drivers will use all lower or upper + * case names. + */ + if (parse_events__decode_legacy_cache(name, /*extended_pmu_type=*/0, &config) == 0) { + pr_warning("sysfs event '%s' should be all lower/upper case, it will be matched using legacy encoding.", + name); + return true; + } + return false; } static int test__pmu_event_names(struct test_suite *test __maybe_unused, |