Re: [PATCH 2/3] perf: collect BPF metadata from existing BPF programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 04, 2025 at 02:40:34PM -0700, Namhyung Kim wrote:
> On Tue, Jun 03, 2025 at 03:29:35PM -0700, Blake Jones wrote:
> > On Tue, Jun 3, 2025 at 3:10 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> > > > Hmmm. Is that documented and tested anywhere? Offhand it sounds like an
> > > > implementation detail that I wouldn't feel great about depending on -
> > > > certainly not without a strong guarantee that it wouldn't change.

> > > Good point.  Maybe BPF folks have some idea?

> > > Anyway the current code generates them together in a function.

> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/events/core.c?h=v6.15#n9825

> > It certainly does, yeah. But I don't want to have that become another
> > instance of https://www.hyrumslaw.com/.

> Thanks for sharing this.

> I'm curious about the semantics of the KSYMBOL and BPF_EVENT.  And I
> feel like there should be a connection between them.

So, the comment in:

tools/perf/util/bpf-event.c

Is:

 * Synthesize PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT for one bpf
 * program. One PERF_RECORD_BPF_EVENT is generated for the program. And
 * one PERF_RECORD_KSYMBOL is generated for each sub program.

which is not so nicely worded tho :-\

"One KSYMBOL per program", followed by "one KSYMBOL per sub program".

But that matches the referenced:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/events/core.c?h=v6.15#n9825

So, for these bpf_metadata_ variables, would that be strictly per
program or would it be perf 'sub program'?

Couldn't get an answer from looking at tools/bpf/bpftool/prog.c, but
seems to be with progs, not subprogs, i.e. just the PERF_RECORD_KSYMBOL
associated with progs (not subprogs) will have those variables.

But then it seems those variables _are_ associated with at least one
PERF_RECORD_KSYMBOL, right?

- Arnaldo

> Song and Jiri, what do you think?

> Thanks,
> Namhyung

> > > > Can you say more about why the duplicated records concern you?
> > >
> > > More data means more chance to lost something.  I don't expect this is
> > > gonna be a practical concern but in general we should pursue less data.
> > 
> > That makes sense. In this case, it will only show up for BPF programs that
> > define "bpf_metadata_" variables (which is already an opt-in action), and
> > the number of variables a given program defines is likely to be quite small.
> > So I think the cost of the marginal increase in data generated is outweighed
> > by the usability and reliability benefits of being able to match these events
> > 1:1 with the KSYMBOL events. If this proves to be a problem in practice,
> > it can be revisited.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux