From: Tao Cui <cui.tao@linux.dev>
To: Jens Axboe <axboe@kernel.dk>
Cc: Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
Leon Hwang <leon.hwang@linux.dev>,
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 v2] blk-iolatency: use guard(spinlock_irqsave)() in iolatency_clear_scaling()
Date: Fri, 17 Jul 2026 15:34:21 +0800 [thread overview]
Message-ID: <20260717073421.2039722-1-cui.tao@linux.dev> (raw)
From: Tao Cui <cuitao@kylinos.cn>
child_lat.lock is acquired with irqsave semantics in both
iolatency_check_latencies() (called from the blkcg_iolatency_done_bio()
softirq path) and blkiolatency_timer_fn() (timer softirq).
iolatency_clear_scaling() instead uses a plain spin_lock(), which only
happens to be safe because both of its callers enter with interrupts
already disabled:
* iolatency_set_limit() runs under queue_lock via blkg_conf_prep(),
which returns with the lock held and interrupts disabled;
* iolatency_pd_offline() runs under queue_lock from blkg_destroy() and
blkcg_deactivate_policy(), both of which take it with spin_lock_irq().
Take the lock with guard(spinlock_irqsave)() so the locking is
self-contained and consistent with the other two sites, instead of
relying on an undocumented caller precondition. No functional change.
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
Changes in v2:
- use guard(spinlock_irqsave)() (suggested by Leon Hwang)
---
block/blk-iolatency.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index cef02b6c5fa9..1cc33aa0b669 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -815,12 +815,11 @@ static void iolatency_clear_scaling(struct blkcg_gq *blkg)
return;
lat_info = &iolat->child_lat;
- spin_lock(&lat_info->lock);
+ guard(spinlock_irqsave)(&lat_info->lock);
atomic_set(&lat_info->scale_cookie, DEFAULT_SCALE_COOKIE);
lat_info->last_scale_event = 0;
lat_info->scale_grp = NULL;
lat_info->scale_lat = 0;
- spin_unlock(&lat_info->lock);
}
}
--
2.43.0
reply other threads:[~2026-07-17 7:34 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=20260717073421.2039722-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=leon.hwang@linux.dev \
--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