has_bh_in_lru() reads another CPU's buffer LRU while that CPU may install or invalidate entries. The local BH LRU lock does not serialize this remote occupancy check, which KCSAN reports as a data race. The check only decides whether to send a drain IPI and never dereferences the sampled pointer. Mark it as an intentional race and use READ_ONCE() to keep the test to a single load. Fixes: 42be35d0390b ("fs: only send IPI to invalidate LRU BH when needed") Signed-off-by: Zhu Jun --- fs/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 5d3852b726d6..1232f1c086ae 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1437,7 +1437,8 @@ bool has_bh_in_lru(int cpu, void *dummy) int i; for (i = 0; i < BH_LRU_SIZE; i++) { - if (b->bhs[i]) + /* Only test occupancy; the remote CPU owns the references. */ + if (data_race(READ_ONCE(b->bhs[i]))) return true; } -- 2.51.0