Files
linux/kernel/sched
zhidao su 9adfcef334 sched_ext: Use READ_ONCE() for the read side of dsq->nr update
scx_bpf_dsq_nr_queued() reads dsq->nr via READ_ONCE() without holding
any lock, making dsq->nr a lock-free concurrently accessed variable.
However, dsq_mod_nr(), the sole writer of dsq->nr, only uses
WRITE_ONCE() on the write side without the matching READ_ONCE() on the
read side:

    WRITE_ONCE(dsq->nr, dsq->nr + delta);
                        ^^^^^^^
                        plain read -- KCSAN data race

The KCSAN documentation requires that if one accessor uses READ_ONCE()
or WRITE_ONCE() on a variable to annotate lock-free access, all other
accesses must also use the appropriate accessor. A plain read on the
right-hand side of WRITE_ONCE() leaves the pair incomplete and will
trigger KCSAN warnings.

Fix by using READ_ONCE() for the read side of the update:

    WRITE_ONCE(dsq->nr, READ_ONCE(dsq->nr) + delta);

This is consistent with scx_bpf_dsq_nr_queued() and makes the
concurrent access annotation complete and KCSAN-clean.

Signed-off-by: zhidao su <suzhidao@xiaomi.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2026-03-02 07:23:00 -10:00
..
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-13 08:47:18 +02:00
2025-07-14 17:16:28 +02:00
2026-01-11 06:09:11 -10:00
2025-08-04 10:51:22 -07:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00
2025-06-11 11:20:53 +02:00