]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched/ext: Prevent update_locked_rq() calls with NULL rq
authorBreno Leitao <leitao@debian.org>
Wed, 16 Jul 2025 17:38:48 +0000 (10:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:58:43 +0000 (08:58 +0200)
commit237c43037b336e36a49eb9f2daac1c7719ec7f8b
tree50c14ccbc258af16221be42ceb26f0caa74d0748
parentcfbc462192aa4104900a2e1a67b116ea9e7075b6
sched/ext: Prevent update_locked_rq() calls with NULL rq

commit e14fd98c6d66cb76694b12c05768e4f9e8c95664 upstream.

Avoid invoking update_locked_rq() when the runqueue (rq) pointer is NULL
in the SCX_CALL_OP and SCX_CALL_OP_RET macros.

Previously, calling update_locked_rq(NULL) with preemption enabled could
trigger the following warning:

    BUG: using __this_cpu_write() in preemptible [00000000]

This happens because __this_cpu_write() is unsafe to use in preemptible
context.

rq is NULL when an ops invoked from an unlocked context. In such cases, we
don't need to store any rq, since the value should already be NULL
(unlocked). Ensure that update_locked_rq() is only called when rq is
non-NULL, preventing calling __this_cpu_write() on preemptible context.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Fixes: 18853ba782bef ("sched_ext: Track currently locked rq")
Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v6.15
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/sched/ext.c