Messages in this thread | | | Date | Tue, 23 Aug 2022 22:32:23 -0700 | From | John Fastabend <> | Subject | Re: [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper |
| |
Namhyung Kim wrote: > Hi Song, > > On Tue, Aug 23, 2022 at 3:19 PM Song Liu <songliubraving@fb.com> wrote: > > > > > > > > > On Aug 23, 2022, at 2:03 PM, Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > The helper is for BPF programs attached to perf_event in order to read > > > event-specific raw data. I followed the convention of the > > > bpf_read_branch_records() helper so that it can tell the size of > > > record using BPF_F_GET_RAW_RECORD flag. > > > > > > The use case is to filter perf event samples based on the HW provided > > > data which have more detailed information about the sample. > > > > > > Note that it only reads the first fragment of the raw record. But it > > > seems mostly ok since all the existing PMU raw data have only single > > > fragment and the multi-fragment records are only for BPF output attached > > > to sockets. So unless it's used with such an extreme case, it'd work > > > for most of tracing use cases. > > > > > > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > > > --- > > > I don't know how to test this. As the raw data is available on some > > > hardware PMU only (e.g. AMD IBS). I tried a tracepoint event but it was > > > rejected by the verifier. Actually it needs a bpf_perf_event_data > > > context so that's not an option IIUC. > > > > Can we add a software event that generates raw data for testing? > > Ok, now I think that I can use a bpf-output sw event. It would need > another BPF program to write data to the event and the test program > can read it from BPF using this helper. :) > > Thanks, > Namhyung
Ah good idea. Feel free to carry my ACK to the v2 with the test.
| |