From: Hannes Reinecke <hare@suse.de>
To: Daniel Wagner <dwagner@suse.de>, linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH 2/2] block: hold queue lock while iterating in diskstats_show
Date: Thu, 20 Jan 2022 12:18:24 +0100 [thread overview]
Message-ID: <bcd9ee08-d751-84f4-7334-b107ee3ca294@suse.de> (raw)
In-Reply-To: <20220120105248.117025-3-dwagner@suse.de>
On 1/20/22 11:52 AM, Daniel Wagner wrote:
> The request queues can be freed while we operate on them. Make sure we
> hold a reference when using blk_mq_queue_tag_busy_iter.
>
> RIP: blk_mq_queue_tag_busy_iter
> Call Trace:
> ? blk_mq_hctx_mark_pending
> ? diskstats_show
> ? blk_mq_hctx_mark_pending
> blk_mq_in_flight
> diskstats_show
> ? klist_next
> seq_read
> proc_reg_read
> vfs_read
> ksys_read
> do_syscall_64
> entry_SYSCALL_64_after_hwframe
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> block/genhd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index c9d4386dd177..0e163055a4e6 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1167,10 +1167,13 @@ static int diskstats_show(struct seq_file *seqf, void *v)
> if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
> continue;
> part_stat_read_all(hd, &stat);
> + if (blk_queue_enter(gp->queue, BLK_MQ_REQ_NOWAIT))
> + continue;
> if (queue_is_mq(gp->queue))
> inflight = blk_mq_in_flight(gp->queue, hd);
> else
> inflight = part_in_flight(hd);
> + blk_queue_exit(gp->queue);
>
> seq_printf(seqf, "%4d %7d %pg "
> "%lu %lu %lu %u "
>
While this looks good, it seems to have been cut against an earlier
branch; the code in question looks different in my copy.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
next prev parent reply other threads:[~2022-01-20 11:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 10:52 [PATCH 0/2] fix crash by reading /proc/diskstats Daniel Wagner
2022-01-20 10:52 ` [PATCH 1/2] block: remove commented out code from diskstats_show Daniel Wagner
2022-01-20 11:02 ` Hannes Reinecke
2022-03-04 15:38 ` Daniel Wagner
2022-01-20 10:52 ` [PATCH 2/2] block: hold queue lock while iterating in diskstats_show Daniel Wagner
2022-01-20 11:18 ` Hannes Reinecke [this message]
2022-01-20 12:41 ` Daniel Wagner
2022-01-20 12:56 ` Ming Lei
2022-01-20 13:19 ` Daniel Wagner
2022-01-20 13:51 ` Ming Lei
2022-01-20 14:01 ` Daniel Wagner
2022-01-20 14:06 ` Daniel Wagner
2022-01-20 14:21 ` Christoph Hellwig
2022-01-20 14:34 ` Daniel Wagner
2022-01-20 15:37 ` Ming Lei
2022-01-20 16:29 ` Daniel Wagner
2022-03-04 14:53 ` Daniel Wagner
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=bcd9ee08-d751-84f4-7334-b107ee3ca294@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).