Skip to contentSkip to conversation

block/blk-iocost: annotate committed flag with READ_ONCE/WRITE_ONCE

PATCH New Tao Cui 1 participant 1 message Aug 2

Subsystems (3)
lore
Share & tools
lore

Tao Cui

author
#0 lore raw

PATCH 1/1 block/blk-iocost: annotate committed flag with READ_ONCE/WRITE_ONCE

From: Tao Cui <[email protected]>

The "committed" wait flag is written by iocg_wake_fn() under waitq.lock and read by ioc_rqos_throttle() without the lock, which trips KCSAN. The ordering is already handled by set_current_state()/wake_up() so the race is harmless. Use READ_ONCE()/WRITE_ONCE() to document the intentional lockless access.

---
 block/blk-iocost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-iocost.c +2 -2
index 8b2aeba2e1e3..782bbe2d27b3 100644
@@ -1458,7 +1458,7 @@ static int iocg_wake_fn(struct wait_queue_entry *wq_entry, unsigned mode,
 		return -1;
 
 	iocg_commit_bio(ctx->iocg, wait->bio, wait->abs_cost, cost);
-	wait->committed = true;
+	WRITE_ONCE(wait->committed, true);
 
 	/*
 	 * autoremove_wake_function() removes the wait entry only when it
@@ -2763,7 +2763,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 
 	while (true) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		if (wait.committed)
+		if (READ_ONCE(wait.committed))
 			break;
 		io_schedule();
 	}
Signature · 1 line
2.43.0