perf test pmu: Refactor format test and exposed test APIs
In tests/pmu.c, make a common utility that creates a PMU in a mkdtemp directory and uses regular PMU parsing logic to load that PMU. Formats must still be eagerly loaded as by default the PMU code assumes devices are going to be in sysfs. In util/pmu.[ch], hide perf_pmu__format_parse but add the eager argument to perf_pmu__lookup called by perf_pmus__add_test_pmu. Later patches will eagerly load other non-sysfs files when eager loading is enabled. In tests/pmu.c, rather than manually constructing a list of term arguments, just use the term parsing code from a string. Add more comments and debug logging. Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Bjorn Helgaas <bhelgaas@google.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: Jonathan Corbet <corbet@lwn.net> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Link: https://lore.kernel.org/r/20240502213507.2339733-4-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
785623ee85
commit
aa1551f299
@ -124,7 +124,8 @@ struct perf_pmu *perf_pmus__find(const char *name)
|
||||
return NULL;
|
||||
|
||||
dirfd = perf_pmu__event_source_devices_fd();
|
||||
pmu = perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name);
|
||||
pmu = perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name,
|
||||
/*eager_load=*/false);
|
||||
close(dirfd);
|
||||
|
||||
if (!pmu) {
|
||||
@ -159,7 +160,8 @@ static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name)
|
||||
if (core_pmu && read_sysfs_core_pmus)
|
||||
return NULL;
|
||||
|
||||
return perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name);
|
||||
return perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name,
|
||||
/*eager_load=*/false);
|
||||
}
|
||||
|
||||
static int pmus_cmp(void *priv __maybe_unused,
|
||||
@ -696,3 +698,13 @@ struct perf_pmu *perf_pmus__find_core_pmu(void)
|
||||
{
|
||||
return perf_pmus__scan_core(NULL);
|
||||
}
|
||||
|
||||
struct perf_pmu *perf_pmus__add_test_pmu(int test_sysfs_dirfd, const char *name)
|
||||
{
|
||||
/*
|
||||
* Some PMU functions read from the sysfs mount point, so care is
|
||||
* needed, hence passing the eager_load flag to load things like the
|
||||
* format files.
|
||||
*/
|
||||
return perf_pmu__lookup(&other_pmus, test_sysfs_dirfd, name, /*eager_load=*/true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user