[PATCH v2] buffer: Annotate the remote buffer LRU occupancy check

From: Zhu Jun

Date: Wed Nov 11 2026 - 20:58:50 EST


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 the occupancy check as an intentional data
race with data_race().

Fixes: 42be35d0390b ("fs: only send IPI to invalidate LRU BH when needed")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
Changes in v2:
- Use data_race() without READ_ONCE().
- Drop the added comment, as suggested by Jan Kara.

fs/buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 5d3852b726d6..2d2d61495b4d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1437,7 +1437,7 @@ bool has_bh_in_lru(int cpu, void *dummy)
int i;

for (i = 0; i < BH_LRU_SIZE; i++) {
- if (b->bhs[i])
+ if (data_race(b->bhs[i]))
return true;
}

--
2.51.0