Commit 07d2b820 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf test parse-events: Test complex name has required event format

test__checkevent_complex_name will use an "event" format which if not
present, such as with a placeholder PMU, will cause test failures. Skip
the test in this case to avoid failures in restricted environments.

Add perf_pmu__has_format utility as a general PMU utility.

Fixes: 628eaa4e ("perf pmus: Add placeholder core PMU")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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/20230706183705.601412-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 34bc65d6
...@@ -1631,6 +1631,16 @@ static bool test__pmu_cpu_valid(void) ...@@ -1631,6 +1631,16 @@ static bool test__pmu_cpu_valid(void)
return !!perf_pmus__find("cpu"); return !!perf_pmus__find("cpu");
} }
static bool test__pmu_cpu_event_valid(void)
{
struct perf_pmu *pmu = perf_pmus__find("cpu");
if (!pmu)
return false;
return perf_pmu__has_format(pmu, "event");
}
static bool test__intel_pt_valid(void) static bool test__intel_pt_valid(void)
{ {
return !!perf_pmus__find("intel_pt"); return !!perf_pmus__find("intel_pt");
...@@ -2179,7 +2189,7 @@ static const struct evlist_test test__events_pmu[] = { ...@@ -2179,7 +2189,7 @@ static const struct evlist_test test__events_pmu[] = {
}, },
{ {
.name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp", .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
.valid = test__pmu_cpu_valid, .valid = test__pmu_cpu_event_valid,
.check = test__checkevent_complex_name, .check = test__checkevent_complex_name,
/* 3 */ /* 3 */
}, },
......
...@@ -1440,6 +1440,17 @@ void perf_pmu__del_formats(struct list_head *formats) ...@@ -1440,6 +1440,17 @@ void perf_pmu__del_formats(struct list_head *formats)
} }
} }
bool perf_pmu__has_format(const struct perf_pmu *pmu, const char *name)
{
struct perf_pmu_format *format;
list_for_each_entry(format, &pmu->format, list) {
if (!strcmp(format->name, name))
return true;
}
return false;
}
bool is_pmu_core(const char *name) bool is_pmu_core(const char *name)
{ {
return !strcmp(name, "cpu") || !strcmp(name, "cpum_cf") || is_sysfs_pmu_core(name); return !strcmp(name, "cpu") || !strcmp(name, "cpum_cf") || is_sysfs_pmu_core(name);
......
...@@ -234,6 +234,7 @@ int perf_pmu__new_format(struct list_head *list, char *name, ...@@ -234,6 +234,7 @@ int perf_pmu__new_format(struct list_head *list, char *name,
void perf_pmu__set_format(unsigned long *bits, long from, long to); void perf_pmu__set_format(unsigned long *bits, long from, long to);
int perf_pmu__format_parse(int dirfd, struct list_head *head); int perf_pmu__format_parse(int dirfd, struct list_head *head);
void perf_pmu__del_formats(struct list_head *formats); void perf_pmu__del_formats(struct list_head *formats);
bool perf_pmu__has_format(const struct perf_pmu *pmu, const char *name);
bool is_pmu_core(const char *name); bool is_pmu_core(const char *name);
bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu); bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu);
......
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