Skip to content

Commit 1dde502

Browse files
devnexenhtejun
authored andcommitted
sched_ext: Use READ_ONCE() for scx_slice_bypass_us in scx_bypass()
Commit 0927780 ("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 0927780 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>
1 parent 8ce8d05 commit 1dde502

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/sched/ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4137,7 +4137,7 @@ static void scx_bypass(bool bypass)
41374137
WARN_ON_ONCE(scx_bypass_depth <= 0);
41384138
if (scx_bypass_depth != 1)
41394139
goto unlock;
4140-
WRITE_ONCE(scx_slice_dfl, scx_slice_bypass_us * NSEC_PER_USEC);
4140+
WRITE_ONCE(scx_slice_dfl, READ_ONCE(scx_slice_bypass_us) * NSEC_PER_USEC);
41414141
bypass_timestamp = ktime_get_ns();
41424142
if (sch)
41434143
scx_add_event(sch, SCX_EV_BYPASS_ACTIVATE, 1);

0 commit comments

Comments
 (0)