lkml.org 
[lkml]   [2022]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper
Date


> On Aug 26, 2022, at 2:12 PM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Fri, Aug 26, 2022 at 1:59 PM Song Liu <songliubraving@fb.com> wrote:
>>
>>
>>
>>> On Aug 26, 2022, at 12:30 PM, Namhyung Kim <namhyung@kernel.org> wrote:
>>>
>>> On Fri, Aug 26, 2022 at 11:45 AM Song Liu <songliubraving@fb.com> wrote:
>>>
>>>>> And actually, we can just read ctx->data and get the raw record,
>>>>> right..?
>>>>
>>>> Played with this for a little bit. ctx->data appears to be not
>>>> reliable sometimes. I guess (not 100% sure) this is because we
>>>> call bpf program before event->orig_overflow_handler. We can
>>>> probably add a flag to specify we want to call orig_overflow_handler
>>>> first.
>>>
>>> I'm not sure. The sample_data should be provided by the caller
>>> of perf_event_overflow. So I guess the bpf program should see
>>> a valid ctx->data.
>>
>> Let's dig into this. Maybe we need some small changes in
>> pe_prog_convert_ctx_access.
>
> Sure, can you explain the problem in detail and share your program?

I push the code to

https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/log/?h=test-perf-event

The code is in tools/bpf/perf-test/.

The problem is we cannot get reliable print of data->cpu_entry in
/sys/kernel/tracing/trace.

>
>>
>>> Also I want to control calling the orig_overflow_handler based
>>> on the return value of the BPF program. So calling the orig
>>> handler before BPF won't work for me. :)
>>
>> Interesting. Could you share more information about the use case?
>
> Well.. it's nothing new. The bpf_overflow_handler calls the
> orig_overflow_handler (which writes the sample to the buffer)
> only if the BPF returns non zero. Then I can drop unnecessary
> samples based on the sample data by returning 0.
>
> The possible use cases are
> 1. when you want to sample from specific code ranges only
> 2. when hardware sets specific bits in raw data

I like this idea. We already using BPF in counting perf_event.
Now it is time to use it in sampling perf_event. :)

Thanks,
Song

\
 
 \ /
  Last update: 2022-08-26 23:26    [W:3.826 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site