public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Marco Elver <elver@google.com>, Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ian Rogers <irogers@google.com>,
	linux-perf-users <linux-perf-users@vger.kernel.org>
Subject: Re: [PATCH] perf test: Skip sigtrap test on old kernels
Date: Tue, 06 Sep 2022 17:56:37 -0300	[thread overview]
Message-ID: <F172EC4B-1CFC-46A5-9DC3-146EDF8F5BDF@gmail.com> (raw)
In-Reply-To: <CANpmjNMHX2S-29Tyw+zKyaWT7saAiEegxbJapQFs7duJTTncdw@mail.gmail.com>



On September 6, 2022 5:50:05 PM GMT-03:00, Marco Elver <elver@google.com> wrote:
>On Tue, 6 Sept 2022 at 20:31, Namhyung Kim <namhyung@kernel.org> wrote:
>>
>> On Tue, Sep 6, 2022 at 5:45 AM Arnaldo Carvalho de Melo <acme@kernel.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@kernel.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@google.com>
>> > > > Signed-off-by: Namhyung Kim <namhyung@kernel.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?

>
>Some other options:
>
>1. Provide a way to disable certain tests, if it's known they will
>fail for otherwise benign reasons i.e. no support.
>
>2. Provide a command line option to skip instead of fail tests where
>perf_event_open() returns some particular errnos. The default will be
>fail, but you can then choose to trust that failure of
>perf_event_open() means no support, and pass the option.

  reply	other threads:[~2022-09-06 20:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-03  0:02 [PATCH] perf test: Skip sigtrap test on old kernels Namhyung Kim
2022-09-03  6:52 ` Marco Elver
2022-09-06 12:45   ` Arnaldo Carvalho de Melo
2022-09-06 18:31     ` Namhyung Kim
2022-09-06 20:50       ` Marco Elver
2022-09-06 20:56         ` Arnaldo Carvalho de Melo [this message]
2022-09-06 22:52           ` Namhyung Kim
2022-09-26 15:06   ` James Clark
2022-09-26 16:19     ` Namhyung Kim
2022-09-27  8:48       ` James Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F172EC4B-1CFC-46A5-9DC3-146EDF8F5BDF@gmail.com \
    --to=arnaldo.melo@gmail.com \
    --cc=acme@kernel.org \
    --cc=elver@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox