From: Tao Cui <cui.tao@linux.dev>
To: tj@kernel.org, axboe@kernel.dk
Cc: josef@toxicpanda.com, cgroups@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
cui.tao@linux.dev, Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH] block/blk-iocost: annotate committed flag with READ_ONCE/WRITE_ONCE
Date: Sun, 2 Aug 2026 23:17:55 +0800 [thread overview]
Message-ID: <20260802151755.35511-1-cui.tao@linux.dev> (raw)
From: Tao Cui <cuitao@kylinos.cn>
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.
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
block/blk-iocost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 8b2aeba2e1e3..782bbe2d27b3 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -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();
}
--
2.43.0
reply other threads:[~2026-08-02 15:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260802151755.35511-1-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=cuitao@kylinos.cn \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox