Files
linux-stable-mirror/kernel
zhidao suandGreg Kroah-Hartman d81d519f12 sched_ext: Use WRITE_ONCE() for the write side of dsq->seq update
[ Upstream commit 7a8464555d ]

bpf_iter_scx_dsq_new() reads dsq->seq via READ_ONCE() without holding
any lock, making dsq->seq a lock-free concurrently accessed variable.
However, dispatch_enqueue(), the sole writer of dsq->seq, uses a plain
increment without the matching WRITE_ONCE() on the write side:

    dsq->seq++;
    ^^^^^^^^^^^
    plain write -- 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 write leaves
the pair incomplete and will trigger KCSAN warnings.

Fix by using WRITE_ONCE() for the write side of the update:

    WRITE_ONCE(dsq->seq, dsq->seq + 1);

This is consistent with bpf_iter_scx_dsq_new() 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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2026-04-02 13:09:29 +02:00
..
2025-11-24 10:35:59 +01:00
2025-06-27 11:11:45 +01:00
2026-03-25 11:08:24 +01:00
2024-10-09 12:47:19 -07:00
2024-09-27 08:18:43 -07:00
2025-12-18 13:54:50 +01:00