FAILED: patch "[PATCH] bpf: Disable preemption in bpf_get_stackid" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 15f1bd8574662f1b7b26aaa2e23ebf4066f0117d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090354-evolution-kitty-6754@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 15f1bd8574662f1b7b26aaa2e23ebf4066f0117d Mon Sep 17 00:00:00 2001
From: Jiri Olsa <[email protected]>
Date: Mon, 3 Aug 2026 23:01:42 +0200
Subject: [PATCH] bpf: Disable preemption in bpf_get_stackid
The get_perf_callchain call needs disabled preemption plus we need it disabled as long as we access its returned trace entries buffer.
Note the bpf_get_stackid_pe function is executed already with preemption disabled.
kernel/bpf/stackmap.c +13 -11
@@ -632,20 +632,22 @@ BPF_CALL_3(bpf_get_stackid, struct pt_regs *, regs, struct bpf_map *, map,return -EINVAL ; max_depth =stack_map_calculate_max_depth (map->value_size, elem_size, flags); - trace =get_perf_callchain (regs, kernel, user, max_depth, - false, false,0 ); -if (unlikely (!trace)) -/* couldn't fetch the stack trace */ -return -EFAULT ; +scoped_guard (preempt) { + trace =get_perf_callchain (regs, kernel, user, max_depth, + false, false,0 ); +if (unlikely (!trace)) +/* couldn't fetch the stack trace */ +return -EFAULT ; - err =stackid_fastpath (&stackid, map, trace, flags); -if (err != -ENOENT ) -return err; + err =stackid_fastpath (&stackid, map, trace, flags); +if (err != -ENOENT ) +return err; - new_bucket =stackid_new_bucket (&stackid, map); -if (!new_bucket) -return -ENOMEM ; + new_bucket =stackid_new_bucket (&stackid, map); +if (!new_bucket) +return -ENOMEM ; + }return stackid_install (&stackid, map, new_bucket, flags); }
Sasha Levin
maintainerPATCH 1/2 bpf: Factor stackid_init function from __bpf_get_stackid
From: Jiri Olsa <[email protected]>
[ Upstream commit 15b837759a97237d647962f9943afe0d55af615a ]
The new stackid_init function stores all the necessary bits for stackid trace and it will be used by other functions in following changes.
[ Stable 6.1 note: Fold in the three intervening stack-ID refactors needed by the follow-up preemption fix. Adapt the older build-ID path to copy perf-owned IPs before that fix ends its preemption guard, and reshape the legacy get_perf_callchain() interface to the follow-up call form while leaving the unavailable deferred-unwind argument unused. ]
Stable-dep-of: 15f1bd857466 ("bpf: Disable preemption in bpf_get_stackid")
--- include/linux/perf_event.h | 4 +- kernel/bpf/stackmap.c | 267 +++++++++++++++++++++++++------------ kernel/events/callchain.c | 8 +- kernel/events/core.c | 4 +- 4 files changed, 193 insertions(+), 90 deletions(-)
include/linux/perf_event.h +2 -2
@@ -1361,8 +1361,8 @@ DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);extern void perf_callchain_user (struct perf_callchain_entry_ctx *entry,struct pt_regs *regs);extern void perf_callchain_kernel (struct perf_callchain_entry_ctx *entry,struct pt_regs *regs);extern struct perf_callchain_entry * -get_perf_callchain (struct pt_regs *regs,u32 init_nr,bool kernel,bool user, -u32 max_stack,bool crosstask,bool add_mark); +get_perf_callchain (struct pt_regs *regs,bool kernel,bool user, +u32 max_stack,bool crosstask,bool add_mark,u64 defer_cookie);extern struct perf_callchain_entry *perf_callchain (struct perf_event *event,struct pt_regs *regs);extern int get_callchain_buffers (int max_stack);extern void put_callchain_buffers (void );
kernel/bpf/stackmap.c +184 -83
397 lines not on this page · raw message
kernel/events/callchain.c +5 -3
@@ -177,13 +177,15 @@ put_callchain_entry(int rctx) }struct perf_callchain_entry * -get_perf_callchain (struct pt_regs *regs,u32 init_nr,bool kernel,bool user, -u32 max_stack,bool crosstask,bool add_mark) +get_perf_callchain (struct pt_regs *regs,bool kernel,bool user, +u32 max_stack,bool crosstask,bool add_mark,u64 defer_cookie) {struct perf_callchain_entry *entry;struct perf_callchain_entry_ctx ctx;int rctx; + (void )defer_cookie; +/* crosstask is not supported for user stacks */ if (crosstask && user && !kernel)return NULL ;
@@ -194,7 +196,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, ctx.entry = entry; ctx.max_stack = max_stack; - ctx.nr = entry->nr = init_nr; + ctx.nr = entry->nr =0 ; ctx.contexts =0 ; ctx.contexts_maxed = false;
kernel/events/core.c +2 -2
@@ -7519,8 +7519,8 @@ perf_callchain(struct perf_event *event, struct pt_regs *regs)if (!kernel && !user)return &__empty_callchain; - callchain =get_perf_callchain (regs,0 , kernel, user, - max_stack, crosstask, true); + callchain =get_perf_callchain (regs, kernel, user, max_stack, + crosstask, true,0 );return callchain ?: &__empty_callchain; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 bpf: Disable preemption in bpf_get_stackid
From: Jiri Olsa <[email protected]>
[ Upstream commit 15f1bd8574662f1b7b26aaa2e23ebf4066f0117d ]
The get_perf_callchain call needs disabled preemption plus we need it disabled as long as we access its returned trace entries buffer.
Note the bpf_get_stackid_pe function is executed already with preemption disabled.
--- kernel/bpf/stackmap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
kernel/bpf/stackmap.c +13 -11
@@ -378,20 +378,22 @@ BPF_CALL_3(bpf_get_stackid, struct pt_regs *, regs, struct bpf_map *, map,return -EINVAL ; max_depth =stack_map_calculate_max_depth (map->value_size, elem_size, flags); - trace =get_perf_callchain (regs, kernel, user, max_depth, - false, false,0 ); -if (unlikely (!trace)) -/* couldn't fetch the stack trace */ -return -EFAULT ; +scoped_guard (preempt) { + trace =get_perf_callchain (regs, kernel, user, max_depth, + false, false,0 ); +if (unlikely (!trace)) +/* couldn't fetch the stack trace */ +return -EFAULT ; - err =stackid_fastpath (&stackid, map, trace, flags); -if (err != -ENOENT ) -return err; + err =stackid_fastpath (&stackid, map, trace, flags); +if (err != -ENOENT ) +return err; - new_bucket =stackid_new_bucket (&stackid, map); -if (!new_bucket) -return -ENOMEM ; + new_bucket =stackid_new_bucket (&stackid, map); +if (!new_bucket) +return -ENOMEM ; + }return stackid_install (&stackid, map, new_bucket, flags); }
Signature · 1 line
2.53.0