[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fVOY_Mq8gC236ThApJ7G7ZfjRuY4RJGGMixOqMkaRWxnQ@mail.gmail.com>
Date: Thu, 27 Apr 2023 13:23:50 -0700
From: Ian Rogers <irogers@...gle.com>
To: "Liang, Kan" <kan.liang@...ux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ahmad Yasin <ahmad.yasin@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Stephane Eranian <eranian@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
Perry Taylor <perry.taylor@...el.com>,
Samantha Alt <samantha.alt@...el.com>,
Caleb Biggers <caleb.biggers@...el.com>,
Weilin Wang <weilin.wang@...el.com>,
Edward Baker <edward.baker@...el.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Florian Fischer <florian.fischer@...q.space>,
Rob Herring <robh@...nel.org>,
Zhengjun Xing <zhengjun.xing@...ux.intel.com>,
John Garry <john.g.garry@...cle.com>,
Kajol Jain <kjain@...ux.ibm.com>,
Sumanth Korikkar <sumanthk@...ux.ibm.com>,
Thomas Richter <tmricht@...ux.ibm.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Ravi Bangoria <ravi.bangoria@....com>,
Leo Yan <leo.yan@...aro.org>,
Yang Jihong <yangjihong1@...wei.com>,
James Clark <james.clark@....com>,
Suzuki Poulouse <suzuki.poulose@....com>,
Kang Minchul <tegongkang@...il.com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 08/40] perf test: Test more sysfs events
On Thu, Apr 27, 2023 at 12:39 PM Liang, Kan <kan.liang@...ux.intel.com> wrote:
>
>
>
> On 2023-04-26 3:00 a.m., Ian Rogers wrote:
> > Parse events for all PMUs, and not just cpu, in test "Parsing of all
> > PMU events from sysfs".
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
>
> Run the test on Cascade Lake and Alder Lake. It looks good.
>
> Tested-by: Kan Liang <kan.liang@...ux.intel.com>
Arnaldo found an issue (strchr with an uninitialized value) that I
have a fix for in v2 of this. The bug got introduced by trying to
separate out the hybrid from the not hybrid changes.
Thanks,
Ian
> Thanks,
> Kan
> > ---
> > tools/perf/tests/parse-events.c | 103 +++++++++++++++++---------------
> > 1 file changed, 55 insertions(+), 48 deletions(-)
> >
> > diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> > index 8068cfd89b84..385bbbc4a409 100644
> > --- a/tools/perf/tests/parse-events.c
> > +++ b/tools/perf/tests/parse-events.c
> > @@ -7,6 +7,7 @@
> > #include "debug.h"
> > #include "pmu.h"
> > #include "pmu-hybrid.h"
> > +#include "pmus.h"
> > #include <dirent.h>
> > #include <errno.h>
> > #include "fncache.h"
> > @@ -2225,49 +2226,24 @@ static int test_pmu(void)
> >
> > static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
> > {
> > - struct stat st;
> > - char path[PATH_MAX];
> > - struct dirent *ent;
> > - DIR *dir;
> > - int ret;
> > -
> > - if (!test_pmu())
> > - return TEST_SKIP;
> > -
> > - snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
> > - sysfs__mountpoint());
> > -
> > - ret = stat(path, &st);
> > - if (ret) {
> > - pr_debug("omitting PMU cpu events tests: %s\n", path);
> > - return TEST_OK;
> > - }
> > + struct perf_pmu *pmu;
> > + int ret = TEST_OK;
> >
> > - dir = opendir(path);
> > - if (!dir) {
> > - pr_debug("can't open pmu event dir: %s\n", path);
> > - return TEST_FAIL;
> > - }
> > + perf_pmus__for_each_pmu(pmu) {
> > + struct stat st;
> > + char path[PATH_MAX];
> > + struct dirent *ent;
> > + DIR *dir;
> > + int err;
> >
> > - ret = TEST_OK;
> > - while ((ent = readdir(dir))) {
> > - struct evlist_test e = { .name = NULL, };
> > - char name[2 * NAME_MAX + 1 + 12 + 3];
> > - int test_ret;
> > + snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/",
> > + sysfs__mountpoint(), pmu->name);
> >
> > - /* Names containing . are special and cannot be used directly */
> > - if (strchr(ent->d_name, '.'))
> > + err = stat(path, &st);
> > + if (err) {
> > + pr_debug("skipping PMU %s events tests: %s\n", pmu->name, path);
> > + ret = combine_test_results(ret, TEST_SKIP);
> > continue;
> > -
> > - snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
> > -
> > - e.name = name;
> > - e.check = test__checkevent_pmu_events;
> > -
> > - test_ret = test_event(&e);
> > - if (test_ret != TEST_OK) {
> > - pr_debug("Test PMU event failed for '%s'", name);
> > - ret = combine_test_results(ret, test_ret);
> > }
> > /*
> > * Names containing '-' are recognized as prefixes and suffixes
> > @@ -2282,17 +2258,48 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
> > if (strchr(ent->d_name, '-'))
> > continue;
> >
> > - snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
> > - e.name = name;
> > - e.check = test__checkevent_pmu_events_mix;
> > - test_ret = test_event(&e);
> > - if (test_ret != TEST_OK) {
> > - pr_debug("Test PMU event failed for '%s'", name);
> > - ret = combine_test_results(ret, test_ret);
> > + dir = opendir(path);
> > + if (!dir) {
> > + pr_debug("can't open pmu event dir: %s\n", path);
> > + ret = combine_test_results(ret, TEST_SKIP);
> > + continue;
> > }
> > - }
> >
> > - closedir(dir);
> > + while ((ent = readdir(dir))) {
> > + struct evlist_test e = { .name = NULL, };
> > + char name[2 * NAME_MAX + 1 + 12 + 3];
> > + int test_ret;
> > +
> > + /* Names containing . are special and cannot be used directly */
> > + if (strchr(ent->d_name, '.'))
> > + continue;
> > +
> > + snprintf(name, sizeof(name), "%s/event=%s/u", pmu->name, ent->d_name);
> > +
> > + e.name = name;
> > + e.check = test__checkevent_pmu_events;
> > +
> > + test_ret = test_event(&e);
> > + if (test_ret != TEST_OK) {
> > + pr_debug("Test PMU event failed for '%s'", name);
> > + ret = combine_test_results(ret, test_ret);
> > + }
> > +
> > + if (!is_pmu_core(pmu->name))
> > + continue;
> > +
> > + snprintf(name, sizeof(name), "%s:u,%s/event=%s/u", ent->d_name, pmu->name, ent->d_name);
> > + e.name = name;
> > + e.check = test__checkevent_pmu_events_mix;
> > + test_ret = test_event(&e);
> > + if (test_ret != TEST_OK) {
> > + pr_debug("Test PMU event failed for '%s'", name);
> > + ret = combine_test_results(ret, test_ret);
> > + }
> > + }
> > +
> > + closedir(dir);
> > + }
> > return ret;
> > }
> >
Powered by blists - more mailing lists