From: Damien Le Moal <dlemoal@kernel.org>
To: Nilay Shroff <nilay@linux.ibm.com>, linux-block@vger.kernel.org
Cc: hch@lst.de, ming.lei@redhat.com, hare@suse.de, axboe@kernel.dk,
gjoyce@ibm.com
Subject: Re: [PATCH] block: protect debugfs attributes using q->elevator_lock
Date: Wed, 12 Mar 2025 19:51:04 +0900 [thread overview]
Message-ID: <3e26b52a-0bc7-438d-8ae4-29ac27268cad@kernel.org> (raw)
In-Reply-To: <20250312102903.3584358-1-nilay@linux.ibm.com>
On 3/12/25 19:28, Nilay Shroff wrote:
> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> index adf5f0697b6b..d26a6df945bd 100644
> --- a/block/blk-mq-debugfs.c
> +++ b/block/blk-mq-debugfs.c
> @@ -347,11 +347,16 @@ static int hctx_busy_show(void *data, struct seq_file *m)
> {
> struct blk_mq_hw_ctx *hctx = data;
> struct show_busy_params params = { .m = m, .hctx = hctx };
> + int res;
>
> + res = mutex_lock_interruptible(&hctx->queue->elevator_lock);
> + if (res)
> + goto out;
There is no need for the goto here. You can "return res;" directly.
Same comment for all the other changes below.
> blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq,
> ¶ms);
> -
> - return 0;
> + mutex_unlock(&hctx->queue->elevator_lock);
> +out:
> + return res;
And you can keep the "return 0;" here.
> }
>
> static const char *const hctx_types[] = {
> @@ -400,12 +405,12 @@ static int hctx_tags_show(void *data, struct seq_file *m)
> struct request_queue *q = hctx->queue;
> int res;
>
> - res = mutex_lock_interruptible(&q->sysfs_lock);
> + res = mutex_lock_interruptible(&q->elevator_lock);
> if (res)
> goto out;
> if (hctx->tags)
> blk_mq_debugfs_tags_show(m, hctx->tags);
> - mutex_unlock(&q->sysfs_lock);
> + mutex_unlock(&q->elevator_lock);
>
> out:
> return res;
> @@ -417,12 +422,12 @@ static int hctx_tags_bitmap_show(void *data, struct seq_file *m)
> struct request_queue *q = hctx->queue;
> int res;
>
> - res = mutex_lock_interruptible(&q->sysfs_lock);
> + res = mutex_lock_interruptible(&q->elevator_lock);
> if (res)
> goto out;
> if (hctx->tags)
> sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m);
> - mutex_unlock(&q->sysfs_lock);
> + mutex_unlock(&q->elevator_lock);
>
> out:
> return res;
> @@ -434,12 +439,12 @@ static int hctx_sched_tags_show(void *data, struct seq_file *m)
> struct request_queue *q = hctx->queue;
> int res;
>
> - res = mutex_lock_interruptible(&q->sysfs_lock);
> + res = mutex_lock_interruptible(&q->elevator_lock);
> if (res)
> goto out;
> if (hctx->sched_tags)
> blk_mq_debugfs_tags_show(m, hctx->sched_tags);
> - mutex_unlock(&q->sysfs_lock);
> + mutex_unlock(&q->elevator_lock);
>
> out:
> return res;
> @@ -451,12 +456,12 @@ static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m)
> struct request_queue *q = hctx->queue;
> int res;
>
> - res = mutex_lock_interruptible(&q->sysfs_lock);
> + res = mutex_lock_interruptible(&q->elevator_lock);
> if (res)
> goto out;
> if (hctx->sched_tags)
> sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m);
> - mutex_unlock(&q->sysfs_lock);
> + mutex_unlock(&q->elevator_lock);
>
> out:
> return res;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 22600420799c..709a32022c78 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -568,9 +568,9 @@ struct request_queue {
> * nr_requests and wbt latency, this lock also protects the sysfs attrs
> * nr_requests and wbt_lat_usec. Additionally the nr_hw_queues update
> * may modify hctx tags, reserved-tags and cpumask, so this lock also
> - * helps protect the hctx attrs. To ensure proper locking order during
> - * an elevator or nr_hw_queue update, first freeze the queue, then
> - * acquire ->elevator_lock.
> + * helps protect the hctx sysfs/debugfs attrs. To ensure proper locking
> + * order during an elevator or nr_hw_queue update, first freeze the
> + * queue, then acquire ->elevator_lock.
> */
> struct mutex elevator_lock;
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-03-12 10:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 10:28 [PATCH] block: protect debugfs attributes using q->elevator_lock Nilay Shroff
2025-03-12 10:51 ` Damien Le Moal [this message]
2025-03-12 11:03 ` Nilay Shroff
2025-03-12 11:08 ` Nilay Shroff
2025-03-12 14:12 ` Christoph Hellwig
2025-03-12 15:19 ` Nilay Shroff
2025-03-13 7:54 ` Christoph Hellwig
2025-03-13 11:48 ` Nilay Shroff
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=3e26b52a-0bc7-438d-8ae4-29ac27268cad@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=gjoyce@ibm.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=nilay@linux.ibm.com \
/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