[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7chkXTtuzc+5eHq7vvTcw05RS6MqYK-WTVrfZxPaC_ppjQ@mail.gmail.com>
Date: Tue, 6 Sep 2022 15:52:04 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
Cc: Marco Elver <elver@...gle.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>, Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
LKML <linux-kernel@...r.kernel.org>,
Ian Rogers <irogers@...gle.com>,
linux-perf-users <linux-perf-users@...r.kernel.org>
Subject: Re: [PATCH] perf test: Skip sigtrap test on old kernels
On Tue, Sep 6, 2022 at 1:56 PM Arnaldo Carvalho de Melo
<arnaldo.melo@...il.com> wrote:
>
>
>
> On September 6, 2022 5:50:05 PM GMT-03:00, Marco Elver <elver@...gle.com> wrote:
> >On Tue, 6 Sept 2022 at 20:31, Namhyung Kim <namhyung@...nel.org> wrote:
> >>
> >> On Tue, Sep 6, 2022 at 5:45 AM Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
> >> >
> >> > Em Sat, Sep 03, 2022 at 08:52:01AM +0200, Marco Elver escreveu:
> >> > > On Sat, 3 Sept 2022 at 02:02, Namhyung Kim <namhyung@...nel.org> wrote:
> >> > > >
> >> > > > If it runs on an old kernel, perf_event_open would fail because of the
> >> > > > new fields sigtrap and sig_data. Just skip the test if it failed.
> >> > > >
> >> > > > Cc: Marco Elver <elver@...gle.com>
> >> > > > Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> >> > > > ---
> >> > > > tools/perf/tests/sigtrap.c | 1 +
> >> > > > 1 file changed, 1 insertion(+)
> >> > > >
> >> > > > diff --git a/tools/perf/tests/sigtrap.c b/tools/perf/tests/sigtrap.c
> >> > > > index e32ece90e164..7057566e6ae4 100644
> >> > > > --- a/tools/perf/tests/sigtrap.c
> >> > > > +++ b/tools/perf/tests/sigtrap.c
> >> > > > @@ -140,6 +140,7 @@ static int test__sigtrap(struct test_suite *test __maybe_unused, int subtest __m
> >> > > > fd = sys_perf_event_open(&attr, 0, -1, -1, perf_event_open_cloexec_flag());
> >> > > > if (fd < 0) {
> >> > > > pr_debug("FAILED sys_perf_event_open(): %s\n", str_error_r(errno, sbuf, sizeof(sbuf)));
> >> > > > + ret = TEST_SKIP;
> >> > >
> >> > > Wouldn't we be interested if perf_event_open() fails because it could
> >> > > actually be a bug? By skipping we'll be more likely to miss the fact
> >> > > there's a real problem.
> >> > >
> >> > > That's my naive thinking at least - what do other perf tests usually
> >> > > do in this case?
> >> >
> >> > Yeah, I was going to try and check if this is the only way that, with
> >> > the given arguments, perf_event_open would fail, but its better to at
> >> > least check errno against -EINVAL or something?
> >>
> >> EINVAL would be too generic and the kernel returns it in many places.
> >> I really wish we could have a better error reporting mechanism.
> >>
> >> Maybe we could retry perf_event_open with sigtrap and sig_data cleared.
> >> If it succeeded, then we can skip the test. If it still failed, then report
> >> the error. But it still couldn't find a bug in the sigtrap code.
> >> What do you think?
> >
> >Yes, that's what I meant, that it could point out an issue with
> >sigtrap perf_event_open().
> >
> >If there's no clear way to determine if it's just not supported or a
> >bug, it'd be better to leave it as-is.
>
> perf could go fancy and try to add a probe using a source file+line where older kernels would fail 8-)
>
> Anyway, perf already does all sorts of kernel capability checks, perhaps this is one of can for sure detect it's something available :-/
>
> One new way could be to look at BTF?
Yeah, we could check BTF if it had the attr.sigtrap field and skip if not.
Let me see how I can do that. :)
Thanks,
Namhyung
Powered by blists - more mailing lists