OSDN Git Service

perf test: Use valid for PMU tests
authorIan Rogers <irogers@google.com>
Tue, 2 May 2023 22:38:18 +0000 (15:38 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 15 May 2023 12:12:10 +0000 (09:12 -0300)
Rather than skip all tests in test__events_pmu if PMU cpu isn't
present, use the per-test valid test. This allows the running of
software PMU tests on hybrid and arm systems.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kan 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-12-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/parse-events.c

index 3721a21..c06fa76 100644 (file)
@@ -1432,6 +1432,11 @@ static int test__checkevent_config_cache(struct evlist *evlist)
        return TEST_OK;
 }
 
+static bool test__pmu_cpu_valid(void)
+{
+       return !!perf_pmu__find("cpu");
+}
+
 static bool test__intel_pt_valid(void)
 {
        return !!perf_pmu__find("intel_pt");
@@ -1981,21 +1986,25 @@ static const struct evlist_test test__events[] = {
 static const struct evlist_test test__events_pmu[] = {
        {
                .name  = "cpu/config=10,config1,config2=3,period=1000/u",
+               .valid = test__pmu_cpu_valid,
                .check = test__checkevent_pmu,
                /* 0 */
        },
        {
                .name  = "cpu/config=1,name=krava/u,cpu/config=2/u",
+               .valid = test__pmu_cpu_valid,
                .check = test__checkevent_pmu_name,
                /* 1 */
        },
        {
                .name  = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
+               .valid = test__pmu_cpu_valid,
                .check = test__checkevent_pmu_partial_time_callgraph,
                /* 2 */
        },
        {
                .name  = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
+               .valid = test__pmu_cpu_valid,
                .check = test__checkevent_complex_name,
                /* 3 */
        },
@@ -2211,21 +2220,6 @@ static int test__terms2(struct test_suite *test __maybe_unused, int subtest __ma
        return test_terms(test__terms, ARRAY_SIZE(test__terms));
 }
 
-static int test_pmu(void)
-{
-       struct stat st;
-       char path[PATH_MAX];
-       int ret;
-
-       snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
-                sysfs__mountpoint());
-
-       ret = stat(path, &st);
-       if (ret)
-               pr_debug("omitting PMU cpu tests\n");
-       return !ret;
-}
-
 static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
 {
        struct perf_pmu *pmu;
@@ -2311,9 +2305,6 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
 
 static int test__pmu_events2(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
 {
-       if (!test_pmu())
-               return TEST_SKIP;
-
        return test_events(test__events_pmu, ARRAY_SIZE(test__events_pmu));
 }