FAILED: patch "[PATCH] sched_ext: Disable preemption between scx_claim_exit() and" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-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.12.y
git checkout FETCH_HEAD
git cherry-pick -x 83236b2e43dba00bee5b82eb5758816b1a674f6a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026031737-imprecise-trodden-af5f@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 83236b2e43dba00bee5b82eb5758816b1a674f6a Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Tue, 24 Feb 2026 21:39:58 -1000
Subject: [PATCH] sched_ext: Disable preemption between scx_claim_exit() and
kicking helper work
scx_claim_exit() atomically sets exit_kind, which prevents scx_error() from triggering further error handling. After claiming exit, the caller must kick the helper kthread work which initiates bypass mode and teardown.
If the calling task gets preempted between claiming exit and kicking the helper work, and the BPF scheduler fails to schedule it back (since error handling is now disabled), the helper work is never queued, bypass mode never activates, tasks stop being dispatched, and the system wedges.
Disable preemption across scx_claim_exit() and the subsequent work kicking in all callers - scx_disable() and scx_vexit(). Add lockdep_assert_preemption_disabled() to scx_claim_exit() to enforce the requirement.
kernel/sched/ext.c +12 -0
@@ -4423,10 +4423,19 @@ static void scx_disable_workfn(struct kthread_work *work)scx_bypass (false); } +/* +* Claim the exit on @sch. The caller must ensure that the helper kthread work +* is kicked before the current task can be preempted. Once exit_kind is +* claimed, scx_error() can no longer trigger, so if the current task gets +* preempted and the BPF scheduler fails to schedule it back, the helper work +* will never be kicked and the whole system can wedge. +*/ static bool scx_claim_exit (struct scx_sched *sch,enum scx_exit_kind kind) {int none =SCX_EXIT_NONE ; +lockdep_assert_preemption_disabled (); +if (!atomic_try_cmpxchg (&sch->exit_kind, &none, kind))return false;
@@ -4449,6 +4458,7 @@ static void scx_disable(enum scx_exit_kind kind)rcu_read_lock (); sch =rcu_dereference (scx_root);if (sch) { +guard (preempt)();scx_claim_exit (sch, kind);kthread_queue_work (sch->helper, &sch->disable_work); }
@@ -4771,6 +4781,8 @@ static bool scx_vexit(struct scx_sched *sch, {struct scx_exit_info *ei = sch->exit_info; +guard (preempt)(); +if (!scx_claim_exit (sch, kind))return false;
Sasha Levin
maintainerPATCH 1/1 sched_ext: Disable preemption between scx_claim_exit() and kicking helper work
From: Tejun Heo <[email protected]>
[ Upstream commit 83236b2e43dba00bee5b82eb5758816b1a674f6a ]
scx_claim_exit() atomically sets exit_kind, which prevents scx_error() from triggering further error handling. After claiming exit, the caller must kick the helper kthread work which initiates bypass mode and teardown.
If the calling task gets preempted between claiming exit and kicking the helper work, and the BPF scheduler fails to schedule it back (since error handling is now disabled), the helper work is never queued, bypass mode never activates, tasks stop being dispatched, and the system wedges.
Disable preemption across scx_claim_exit() and the subsequent work kicking in all callers - scx_disable() and scx_vexit(). Add lockdep_assert_preemption_disabled() to scx_claim_exit() to enforce the requirement.
--- kernel/sched/ext.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/sched/ext.c +20 -4
@@ -4775,14 +4775,29 @@ static void schedule_scx_ops_disable_work(void)kthread_queue_work (helper, &scx_ops_disable_work); } -static void scx_ops_disable (enum scx_exit_kind kind) +/* +* Claim the exit. The caller must ensure that the helper kthread work +* is kicked before the current task can be preempted. Once exit_kind is +* claimed, scx_error() can no longer trigger, so if the current task gets +* preempted and the BPF scheduler fails to schedule it back, the helper work +* will never be kicked and the whole system can wedge. +*/ +static bool scx_claim_exit (enum scx_exit_kind kind) {int none =SCX_EXIT_NONE ; +lockdep_assert_preemption_disabled (); + +return atomic_try_cmpxchg (&scx_exit_kind, &none, kind); +} + +static void scx_ops_disable (enum scx_exit_kind kind) +{if (WARN_ON_ONCE (kind ==SCX_EXIT_NONE || kind ==SCX_EXIT_DONE )) kind =SCX_EXIT_ERROR ; -atomic_try_cmpxchg (&scx_exit_kind, &none, kind); +guard (preempt)(); +scx_claim_exit (kind);schedule_scx_ops_disable_work (); }
@@ -5082,10 +5097,11 @@ static __printf(3, 4) void scx_ops_exit_kind(enum scx_exit_kind kind, const char *fmt, ...) {struct scx_exit_info *ei = scx_exit_info; -int none =SCX_EXIT_NONE ;va_list args; -if (!atomic_try_cmpxchg (&scx_exit_kind, &none, kind)) +guard (preempt)(); + +if (!scx_claim_exit (kind))return ; ei->exit_code = exit_code;
Signature · 1 line
2.51.0