BPF List
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <song@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper
Date: Mon, 29 Aug 2022 07:20:56 +0000	[thread overview]
Message-ID: <4E6CFFD5-7048-4F64-8F16-70DD6D081ACF@fb.com> (raw)
In-Reply-To: <CAM9d7cg-X6iobbmx3HzCz4H2c20peBVGPt3yf9m3WbqLb5H90A@mail.gmail.com>



> On Aug 26, 2022, at 11:25 PM, Namhyung Kim <namhyung@kernel.org> wrote:
> 
> On Fri, Aug 26, 2022 at 2:26 PM Song Liu <songliubraving@fb.com> wrote:
>> 
>> 
>> 
>>> 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.
> 
> Ah, right.  I've realized that the sample data is passed before full
> initialized.  Please see perf_sample_data_init().  The other members
> are initialized right before written to the ring buffer in the
> orig_overflow_handler (__perf_event_output).
> 
> That explains why pe_prog_convert_ctx_access() handles
> data and period specially.  We need to handle it first.

Thanks for confirming this. I guess we will need a helper (or kfunc) 
for the raw data. 

Shall we make it more generic that we can get other PERF_SAMPLE_*? 

Thanks,
Song




  reply	other threads:[~2022-08-29  7:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 21:03 [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper Namhyung Kim
2022-08-23 22:19 ` Song Liu
2022-08-23 22:45   ` Namhyung Kim
2022-08-24  5:32     ` John Fastabend
2022-08-25 16:57       ` Namhyung Kim
2022-08-25 17:04         ` Song Liu
2022-08-25 17:21           ` Namhyung Kim
2022-08-24  5:31 ` John Fastabend
2022-08-24  6:09   ` Namhyung Kim
2022-08-25 21:33 ` Andrii Nakryiko
2022-08-25 22:08   ` Song Liu
2022-08-25 23:03     ` Andrii Nakryiko
2022-08-26  2:35       ` Song Liu
2022-08-26  5:22         ` Namhyung Kim
2022-08-26  5:53           ` Song Liu
2022-08-26 16:33             ` Namhyung Kim
2022-08-26 18:09               ` Song Liu
2022-08-26 18:44                 ` Song Liu
2022-08-26 19:30                   ` Namhyung Kim
2022-08-26 20:58                     ` Song Liu
2022-08-26 21:12                       ` Namhyung Kim
2022-08-26 21:25                         ` Song Liu
2022-08-27  6:25                           ` Namhyung Kim
2022-08-29  7:20                             ` Song Liu [this message]
2022-08-29 20:11                               ` Namhyung Kim
2022-08-26 19:21                 ` Namhyung Kim
2022-08-26 20:52                   ` Song Liu
2022-08-25 22:13   ` Namhyung Kim
2022-08-25 23:09     ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E6CFFD5-7048-4F64-8F16-70DD6D081ACF@fb.com \
    --to=songliubraving@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox