[PATCH] perf test: Skip watchpoint tests if no watchpoints available

Arnaldo Carvalho de Melo acme at kernel.org
Thu Nov 24 00:33:26 AEDT 2022


Em Tue, Nov 22, 2022 at 12:57:05PM -0800, Ian Rogers escreveu:
> On Tue, Nov 22, 2022 at 11:19 AM Christophe Leroy
> <christophe.leroy at csgroup.eu> wrote:
> >
> >
> >
> > Le 21/11/2022 à 11:27, Naveen N. Rao a écrit :
> > > On IBM Power9, perf watchpoint tests fail since no hardware breakpoints
> > > are available. Detect this by checking the error returned by
> > > perf_event_open() and skip the tests in that case.
> > >
> > > Reported-by: Disha Goel <disgoel at linux.vnet.ibm.com>
> > > Signed-off-by: Naveen N. Rao <naveen.n.rao at linux.vnet.ibm.com>
> > > ---
> > >   tools/perf/tests/wp.c | 12 +++++++-----
> > >   1 file changed, 7 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
> > > index 56455da30341b4..cc8719609b19ea 100644
> > > --- a/tools/perf/tests/wp.c
> > > +++ b/tools/perf/tests/wp.c
> > > @@ -59,8 +59,10 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
> > >       get__perf_event_attr(&attr, wp_type, wp_addr, wp_len);
> > >       fd = sys_perf_event_open(&attr, 0, -1, -1,
> > >                                perf_event_open_cloexec_flag());
> > > -     if (fd < 0)
> > > +     if (fd < 0) {
> > > +             fd = -errno;
> > >               pr_debug("failed opening event %x\n", attr.bp_type);
> > > +     }
> >
> > Do you really need that ?
> >
> > Can't you directly check errno in the caller ?
> 
> errno is very easily clobbered and not clearly set on success - ie,
> it'd be better not to do that.
> 
> Acked-by: Ian Rogers <irogers at google.com>

Thanks, applied.

- Arnaldo



More information about the Linuxppc-dev mailing list