[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP_z_CguNu7KGL+-=WD-8LfZiKaLEe=R=Z6jgtXTr21AzKQNtw@mail.gmail.com>
Date: Thu, 29 May 2025 16:21:01 -0700
From: Blake Jones <blakejones@...gle.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>,
Chun-Tse Shao <ctshao@...gle.com>, Zhongqiu Han <quic_zhonhan@...cinc.com>,
James Clark <james.clark@...aro.org>, Charlie Jenkins <charlie@...osinc.com>,
Andi Kleen <ak@...ux.intel.com>, Dmitry Vyukov <dvyukov@...gle.com>, Leo Yan <leo.yan@....com>,
Yujie Liu <yujie.liu@...el.com>, Graham Woodward <graham.woodward@....com>,
Yicong Yang <yangyicong@...ilicon.com>, Ben Gainey <ben.gainey@....com>,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 2/3] perf: collect BPF metadata from existing BPF programs
Hi Ian,
On Thu, May 29, 2025 at 10:47 AM Ian Rogers <irogers@...gle.com> wrote:
> > + bpf_metadata_event = &metadata->event->bpf_metadata;
> > + *bpf_metadata_event = (struct perf_record_bpf_metadata) {
> > + .header = {
> > + .type = PERF_RECORD_BPF_METADATA,
> > + .size = metadata->event_size,
>
> nit: Could we set the header.size in bpf_metadata_alloc to remove
> metadata->event_size. The code generally doesn't pass a pair of
> perf_event + size around as the size should be in the header.
I can do this initialization of metadata->event->bpf_metadata in
bpf_metadata_alloc(). I'll need to do a bit more work in
synthesize_perf_record_bpf_metadata() before I can get rid of
metadata->event_size, because it needs to allocate an additional
machine->id_hdr_size bytes (see below); I'd just have it get the
value out of metadata->event->header.size instead. Sound good?
Blake
> > +static int synthesize_perf_record_bpf_metadata(const struct bpf_metadata *metadata,
> > + const struct perf_tool *tool,
> > + perf_event__handler_t process,
> > + struct machine *machine)
> > +{
> > + union perf_event *event;
> > + int err = 0;
> > +
> > + event = calloc(1, metadata->event_size + machine->id_hdr_size);
> > + if (!event)
> > + return -1;
> > + memcpy(event, metadata->event, metadata->event_size);
> > + memset((void *)event + event->header.size, 0, machine->id_hdr_size);
> > + event->header.size += machine->id_hdr_size;
> > + for (__u32 index = 0; index < metadata->nr_prog_names; index++) {
> > + memcpy(event->bpf_metadata.prog_name,
> > + metadata->prog_names[index], BPF_PROG_NAME_LEN);
> > + err = perf_tool__process_synth_event(tool, event, machine,
> > + process);
> > + if (err != 0)
> > + break;
> > + }
> > +
> > + free(event);
> > + return err;
> > +}
Powered by blists - more mailing lists