Commit 5a52817e authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf test: Test more sysfs events

Parse events for all PMUs, and not just cpu, in test "Parsing of all
PMU events from sysfs".
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ahmad Yasin <ahmad.yasin@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kang Minchul <tegongkang@gmail.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.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: Rob Herring <robh@kernel.org>
Cc: Samantha Alt <samantha.alt@intel.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20230502223851.2234828-11-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cde61c60
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "debug.h" #include "debug.h"
#include "pmu.h" #include "pmu.h"
#include "pmu-hybrid.h" #include "pmu-hybrid.h"
#include "pmus.h"
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include "fncache.h" #include "fncache.h"
...@@ -558,7 +559,8 @@ static int test__checkevent_pmu_events(struct evlist *evlist) ...@@ -558,7 +559,8 @@ static int test__checkevent_pmu_events(struct evlist *evlist)
struct evsel *evsel = evlist__first(evlist); struct evsel *evsel = evlist__first(evlist);
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type ||
strcmp(evsel->pmu_name, "cpu"));
TEST_ASSERT_VAL("wrong exclude_user", TEST_ASSERT_VAL("wrong exclude_user",
!evsel->core.attr.exclude_user); !evsel->core.attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", TEST_ASSERT_VAL("wrong exclude_kernel",
...@@ -590,7 +592,8 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist) ...@@ -590,7 +592,8 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist)
/* cpu/pmu-event/u*/ /* cpu/pmu-event/u*/
evsel = evsel__next(evsel); evsel = evsel__next(evsel);
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type ||
strcmp(evsel->pmu_name, "cpu"));
TEST_ASSERT_VAL("wrong exclude_user", TEST_ASSERT_VAL("wrong exclude_user",
!evsel->core.attr.exclude_user); !evsel->core.attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", TEST_ASSERT_VAL("wrong exclude_kernel",
...@@ -2225,31 +2228,35 @@ static int test_pmu(void) ...@@ -2225,31 +2228,35 @@ static int test_pmu(void)
static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused) static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{ {
struct perf_pmu *pmu;
int ret = TEST_OK;
if (list_empty(&pmus))
perf_pmu__scan(NULL);
perf_pmus__for_each_pmu(pmu) {
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
struct dirent *ent; struct dirent *ent;
DIR *dir; DIR *dir;
int ret; int err;
if (!test_pmu()) snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/",
return TEST_SKIP; sysfs__mountpoint(), pmu->name);
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
sysfs__mountpoint());
ret = stat(path, &st); err = stat(path, &st);
if (ret) { if (err) {
pr_debug("omitting PMU cpu events tests: %s\n", path); pr_debug("skipping PMU %s events tests: %s\n", pmu->name, path);
return TEST_OK; continue;
} }
dir = opendir(path); dir = opendir(path);
if (!dir) { if (!dir) {
pr_debug("can't open pmu event dir: %s\n", path); pr_debug("can't open pmu event dir: %s\n", path);
return TEST_FAIL; ret = combine_test_results(ret, TEST_SKIP);
continue;
} }
ret = TEST_OK;
while ((ent = readdir(dir))) { while ((ent = readdir(dir))) {
struct evlist_test e = { .name = NULL, }; struct evlist_test e = { .name = NULL, };
char name[2 * NAME_MAX + 1 + 12 + 3]; char name[2 * NAME_MAX + 1 + 12 + 3];
...@@ -2259,7 +2266,7 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest ...@@ -2259,7 +2266,7 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
if (strchr(ent->d_name, '.')) if (strchr(ent->d_name, '.'))
continue; continue;
snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name); snprintf(name, sizeof(name), "%s/event=%s/u", pmu->name, ent->d_name);
e.name = name; e.name = name;
e.check = test__checkevent_pmu_events; e.check = test__checkevent_pmu_events;
...@@ -2269,6 +2276,10 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest ...@@ -2269,6 +2276,10 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
pr_debug("Test PMU event failed for '%s'", name); pr_debug("Test PMU event failed for '%s'", name);
ret = combine_test_results(ret, test_ret); ret = combine_test_results(ret, test_ret);
} }
if (!is_pmu_core(pmu->name))
continue;
/* /*
* Names containing '-' are recognized as prefixes and suffixes * Names containing '-' are recognized as prefixes and suffixes
* due to '-' being a legacy PMU separator. This fails when the * due to '-' being a legacy PMU separator. This fails when the
...@@ -2282,7 +2293,8 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest ...@@ -2282,7 +2293,8 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
if (strchr(ent->d_name, '-')) if (strchr(ent->d_name, '-'))
continue; continue;
snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name); snprintf(name, sizeof(name), "%s:u,%s/event=%s/u",
ent->d_name, pmu->name, ent->d_name);
e.name = name; e.name = name;
e.check = test__checkevent_pmu_events_mix; e.check = test__checkevent_pmu_events_mix;
test_ret = test_event(&e); test_ret = test_event(&e);
...@@ -2293,6 +2305,7 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest ...@@ -2293,6 +2305,7 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
} }
closedir(dir); closedir(dir);
}
return ret; return ret;
} }
......
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