Re: [PATCH v2] perf test: Skip sigtrap test on old kernels

From: Namhyung Kim
Date: Wed Sep 07 2022 - 02:58:26 EST


Hi Song,

On Tue, Sep 6, 2022 at 10:58 PM Song Liu <song@xxxxxxxxxx> wrote:
>
> On Tue, Sep 6, 2022 at 10:04 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > If it runs on an old kernel, perf_event_open would fail because of the
> > new fields sigtrap and sig_data. Just skipping the test could miss an
> > actual bug in the kernel.
> >
> > Let's check BTF if it has the perf_event_attr.sigtrap field.
> >
> > Cc: Marco Elver <elver@xxxxxxxxxx>
> > Cc: Song Liu <songliubraving@xxxxxx>
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> > ---
> > tools/perf/tests/sigtrap.c | 46 +++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 45 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/tests/sigtrap.c b/tools/perf/tests/sigtrap.c
> > index e32ece90e164..32f08ce0f2b0 100644
> > --- a/tools/perf/tests/sigtrap.c
> > +++ b/tools/perf/tests/sigtrap.c
> > @@ -16,6 +16,8 @@
> > #include <sys/syscall.h>
> > #include <unistd.h>
> >
> > +#include <bpf/btf.h>
> > +
>
> Do we need "#ifdef HAVE_BPF_SKEL" for the include part?

Right, it'd be better to move it under the #ifdef. Will change.

>
> Other than this, looks good to me.
>
> Acked-by: Song Liu <song@xxxxxxxxxx>

Thanks for the review!
Namhyung