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: Fri, 26 Aug 2022 18:09:23 +0000 [thread overview]
Message-ID: <C7F3F33B-4A8E-428C-9FED-FB635955C2B1@fb.com> (raw)
In-Reply-To: <CAM9d7cjTtOkRHLOosxHN8PcbVbhTK=uLDGjw8N5=1QiTHcd6rQ@mail.gmail.com>
> On Aug 26, 2022, at 9:33 AM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Thu, Aug 25, 2022 at 10:53 PM Song Liu <song@kernel.org> wrote:
>>
>> On Thu, Aug 25, 2022 at 10:22 PM Namhyung Kim <namhyung@kernel.org> wrote:
>>>
>>> On Thu, Aug 25, 2022 at 7:35 PM Song Liu <songliubraving@fb.com> wrote:
>>>> Actually, since we are on this, can we make it more generic, and handle
>>>> all possible PERF_SAMPLE_* (in enum perf_event_sample_format)? Something
>>>> like:
>>>>
>>>> long bpf_perf_event_read_sample(void *ctx, void *buf, u64 size, u64 flags);
>>>>
>>>> WDYT Namhyung?
>>>
>>> Do you mean reading the whole sample data at once?
>>> Then it needs to parse the sample data format properly
>>> which is non trivial due to a number of variable length
>>> fields like callchains and branch stack, etc.
>>>
>>> Also I'm afraid I might need event configuration info
>>> other than sample data like attr.type, attr.config,
>>> attr.sample_type and so on.
>>>
>>> Hmm.. maybe we can add it to the ctx directly like ctx.attr_type?
>>
>> The user should have access to the perf_event_attr used to
>> create the event. This is also available in ctx->event->attr.
>
> Do you mean from BPF? I'd like to have a generic BPF program
> that can handle various filtering according to the command line
> arguments. I'm not sure but it might do something differently
> for each event based on the attr settings.
Yeah, we can access perf_event_attr from BPF program. Note that
the ctx for perf_event bpf program is struct bpf_perf_event_data_kern:
SEC("perf_event")
int perf_e(struct bpf_perf_event_data_kern *ctx)
{
...
}
struct bpf_perf_event_data_kern {
bpf_user_pt_regs_t *regs;
struct perf_sample_data *data;
struct perf_event *event;
};
Alternatively, we can also have bpf user space configure the BPF
program via a few knobs.
And actually, we can just read ctx->data and get the raw record,
right..?
Thanks,
Song
next prev parent reply other threads:[~2022-08-26 18:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 21:03 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 [this message]
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
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=C7F3F33B-4A8E-428C-9FED-FB635955C2B1@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
all inboxes | Powered by JetHome®