]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Use READ_ONCE() for scx_slice_bypass_us in scx_bypass()
authorDavid Carlier <devnexen@gmail.com>
Fri, 6 Mar 2026 04:50:55 +0000 (04:50 +0000)
committerTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 16:57:23 +0000 (06:57 -1000)
commit1dde502587657045b267f179d7a1ecc7b8a1a265
treede76431f9ce85b5f010903191ddac441863bf328
parent8ce8d0524c136f60a1bddb0951db2999342d7217
sched_ext: Use READ_ONCE() for scx_slice_bypass_us in scx_bypass()

Commit 0927780c90ce ("sched_ext: Use READ_ONCE() for lock-free reads
of module param variables") annotated the plain reads of
scx_slice_bypass_us and scx_bypass_lb_intv_us in bypass_lb_cpu(), but
missed a third site in scx_bypass():

  WRITE_ONCE(scx_slice_dfl, scx_slice_bypass_us * NSEC_PER_USEC);

scx_slice_bypass_us is a module parameter writable via sysfs in
process context through set_slice_us() -> param_set_uint_minmax(),
which performs a plain store without holding bypass_lock. scx_bypass()
reads the variable under bypass_lock, but since the writer does not
take that lock, the two accesses are concurrent.

WRITE_ONCE() only applies volatile semantics to the store of
scx_slice_dfl -- the val expression containing scx_slice_bypass_us is
evaluated as a plain read, providing no protection against concurrent
writes.

Wrap the read with READ_ONCE() to complete the annotation started by
commit 0927780c90ce and make the access KCSAN-clean, consistent with
the existing READ_ONCE(scx_slice_bypass_us) in bypass_lb_cpu().

Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c