From: Peter Zijlstra <peterz@infradead.org>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
kernel-team@fb.com
Subject: Re: [PATCH v2 bpf-next 05/14] bpf: allow to specify user-provided context value for BPF perf links
Date: Tue, 27 Jul 2021 11:11:48 +0200 [thread overview]
Message-ID: <YP/N1HR6GAanBd9m@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210726161211.925206-6-andrii@kernel.org>
On Mon, Jul 26, 2021 at 09:12:02AM -0700, Andrii Nakryiko wrote:
> Add ability for users to specify custom u64 value when creating BPF link for
> perf_event-backed BPF programs (kprobe/uprobe, perf_event, tracepoints).
If I read this right, the value is dependent on the link, not the
program. In which case:
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 2d510ad750ed..97ab46802800 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -762,6 +762,7 @@ struct perf_event {
> #ifdef CONFIG_BPF_SYSCALL
> perf_overflow_handler_t orig_overflow_handler;
> struct bpf_prog *prog;
> + u64 user_ctx;
> #endif
>
> #ifdef CONFIG_EVENT_TRACING
> diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
> index 8ac92560d3a3..4543852f1480 100644
> --- a/include/linux/trace_events.h
> +++ b/include/linux/trace_events.h
> @@ -675,7 +675,7 @@ trace_trigger_soft_disabled(struct trace_event_file *file)
>
> #ifdef CONFIG_BPF_EVENTS
> unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx);
> -int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog);
> +int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog, u64 user_ctx);
This API would be misleading, because it is about setting the program.
> void perf_event_detach_bpf_prog(struct perf_event *event);
> int perf_event_query_prog_array(struct perf_event *event, void __user *info);
> int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *prog);
> @@ -9966,6 +9968,7 @@ static int perf_event_set_bpf_handler(struct perf_event *event, struct bpf_prog
> }
>
> event->prog = prog;
> + event->user_ctx = user_ctx;
> event->orig_overflow_handler = READ_ONCE(event->overflow_handler);
> WRITE_ONCE(event->overflow_handler, bpf_overflow_handler);
> return 0;
Also, the name @user_ctx is a bit confusing. Would something like
@bpf_cookie or somesuch not be a better name?
Combined would it not make more sense to add something like:
extern int perf_event_set_bpf_cookie(struct perf_event *event, u64 cookie);
next prev parent reply other threads:[~2021-07-27 9:14 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 16:11 [PATCH v2 bpf-next 00/14] BPF perf link and user-provided context value Andrii Nakryiko
2021-07-26 16:11 ` [PATCH v2 bpf-next 01/14] bpf: refactor BPF_PROG_RUN into a function Andrii Nakryiko
2021-07-29 16:49 ` Yonghong Song
2021-07-30 4:05 ` Andrii Nakryiko
2021-07-26 16:11 ` [PATCH v2 bpf-next 02/14] bpf: refactor BPF_PROG_RUN_ARRAY family of macros into functions Andrii Nakryiko
2021-07-29 17:04 ` Yonghong Song
2021-07-26 16:12 ` [PATCH v2 bpf-next 03/14] bpf: refactor perf_event_set_bpf_prog() to use struct bpf_prog input Andrii Nakryiko
2021-07-27 8:48 ` Peter Zijlstra
2021-07-29 17:09 ` Yonghong Song
2021-07-26 16:12 ` [PATCH v2 bpf-next 04/14] bpf: implement minimal BPF perf link Andrii Nakryiko
2021-07-27 9:04 ` Peter Zijlstra
2021-07-30 4:23 ` Andrii Nakryiko
2021-07-27 9:12 ` Peter Zijlstra
2021-07-27 20:56 ` Andrii Nakryiko
2021-07-27 15:40 ` Jiri Olsa
2021-07-27 20:56 ` Andrii Nakryiko
2021-07-29 17:35 ` Yonghong Song
2021-07-30 4:16 ` Andrii Nakryiko
2021-07-30 5:42 ` Yonghong Song
2021-07-26 16:12 ` [PATCH v2 bpf-next 05/14] bpf: allow to specify user-provided context value for BPF perf links Andrii Nakryiko
2021-07-27 9:11 ` Peter Zijlstra [this message]
2021-07-27 21:09 ` Andrii Nakryiko
2021-07-28 8:58 ` Peter Zijlstra
2021-07-29 18:00 ` Yonghong Song
2021-07-30 4:31 ` Andrii Nakryiko
2021-07-30 5:49 ` Yonghong Song
2021-07-30 17:48 ` Andrii Nakryiko
2021-07-30 21:34 ` Yonghong Song
2021-07-30 22:06 ` Andrii Nakryiko
2021-07-30 22:28 ` Yonghong Song
2021-07-26 16:12 ` [PATCH v2 bpf-next 06/14] bpf: add bpf_get_user_ctx() BPF helper to access user_ctx value Andrii Nakryiko
2021-07-29 18:17 ` Yonghong Song
2021-07-30 4:49 ` Andrii Nakryiko
2021-07-30 5:53 ` Yonghong Song
2021-07-26 16:12 ` [PATCH v2 bpf-next 07/14] libbpf: re-build libbpf.so when libbpf.map changes Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 08/14] libbpf: remove unused bpf_link's destroy operation, but add dealloc Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 09/14] libbpf: use BPF perf link when supported by kernel Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 10/14] libbpf: add user_ctx support to bpf_link_create() API Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 11/14] libbpf: add user_ctx to perf_event, kprobe, uprobe, and tp attach APIs Andrii Nakryiko
2021-07-30 1:11 ` Rafael David Tinoco
2021-07-26 16:12 ` [PATCH v2 bpf-next 12/14] selftests/bpf: test low-level perf BPF link API Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 13/14] selftests/bpf: extract uprobe-related helpers into trace_helpers.{c,h} Andrii Nakryiko
2021-07-26 16:12 ` [PATCH v2 bpf-next 14/14] selftests/bpf: add user_ctx selftests for high-level APIs 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=YP/N1HR6GAanBd9m@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.