Re: [PATCH bpf-next 1/4] bpf: Add log support for perf link_create
From: Alexei Starovoitov
Date: Wed Dec 02 2026 - 20:41:11 EST
On Wed Dec 2, 2026 at 3:37 PM UTC, Leon Hwang wrote:
> BPF_LINK_CREATE returns -EINVAL for several perf event attach failures.
> It also returns -EEXIST when the perf event already has a program or
> when the same program is attached to the trace event through another
> perf event.
>
> Pass the link log through the perf event attach path so callers can
> tell which check failed. Keep PERF_EVENT_IOC_SET_BPF on the same path
> without a log. Provide a bpf_log() stub for builds without
> CONFIG_BPF_SYSCALL.
>
> Signed-off-by: Leon Hwang <leon.hwang@xxxxxxxxx>
> ---
> include/linux/bpf_verifier.h | 7 ++++
> include/linux/trace_events.h | 9 ++--
> kernel/bpf/syscall.c | 20 +++++----
> kernel/events/core.c | 79 ++++++++++++++++++++++++------------
> kernel/trace/bpf_trace.c | 15 +++++--
> 5 files changed, 91 insertions(+), 39 deletions(-)
>
> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
> index 50b3f8ab9720..a27f66a25618 100644
> --- a/include/linux/bpf_verifier.h
> +++ b/include/linux/bpf_verifier.h
> @@ -1607,8 +1607,15 @@ __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log,
> const char *fmt, va_list args);
> __printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
> const char *fmt, ...);
> +#ifdef CONFIG_BPF_SYSCALL
> __printf(2, 3) void bpf_log(struct bpf_verifier_log *log,
> const char *fmt, ...);
> +#else
> +static inline __printf(2, 3) void bpf_log(struct bpf_verifier_log *log,
> + const char *fmt, ...)
> +{
> +}
> +#endif
> int bpf_vlog_init(struct bpf_verifier_log *log, u32 log_level,
> char __user *log_buf, u32 log_size);
> void bpf_vlog_reset(struct bpf_verifier_log *log, u64 new_pos);
> diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
> index dff8a209875c..0fe900813581 100644
> --- a/include/linux/trace_events.h
> +++ b/include/linux/trace_events.h
> @@ -781,7 +781,8 @@ 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);
> unsigned int trace_call_bpf_faultable(struct trace_event_call *call, void *ctx);
> -int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog, u64 bpf_cookie);
> +int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog, u64 bpf_cookie,
> + struct bpf_verifier_log *log);
This is not landable.
Don't you remember how netdev folks objected to such thing?
Same story here.
pw-bot: cr