Re: [PATCH v2 3/3] perf lock: Print the number of lost entries for BPF

From: Namhyung Kim
Date: Mon Sep 26 2022 - 17:42:44 EST


Hello,

On Mon, Sep 26, 2022 at 1:05 AM Jiri Slaby <jirislaby@xxxxxxxxxx> wrote:
>
> Hi,
>
> On 02. 08. 22, 21:10, Namhyung Kim wrote:
> > Like the normal perf lock contention output, it'd print the number of
> > lost entries for BPF if exists or -v option is passed. Currently it
> > uses BROKEN_CONTENDED stat for the lost count (due to full stack maps).
> ...
> > --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> ...
> > @@ -73,6 +73,9 @@ int enabled;
> > int has_cpu;
> > int has_task;
> >
> > +/* error stat */
> > +unsigned long lost;
>
> I don't know how all this is generated into lock_contention.skel.h. But
> I believe this patch breaks perf build on 32bit:
> > [ 375s] In file included from util/bpf_lock_contention.c:13:
> > [ 375s] util/bpf_skel/lock_contention.skel.h: In function 'lock_contention_bpf__assert':
> > [ 375s] util/bpf_skel/lock_contention.skel.h:537:9: error: static assertion failed: "unexpected size of \'lost\'"
> > [ 375s] 537 | _Static_assert(sizeof(s->bss->lost) == 8, "unexpected size of 'lost'");
> > [ 375s] | ^~~~~~~~~~~~~~
>
> Should the above (and below too) be __u64?

Oops, it seems BPF ABI uses 8-byte long even on 32-bit systems.
Sorry for the inconvenience. Will change.

Thanks,
Namhyung


>
> > --- a/tools/perf/util/lock-contention.h
> > +++ b/tools/perf/util/lock-contention.h
> > @@ -113,6 +113,7 @@ struct lock_contention {
> > struct machine *machine;
> > struct hlist_head *result;
> > unsigned long map_nr_entries;
> > + unsigned long lost;
>
> thanks,
> --
> js
> suse labs
>