From: Damien Le Moal <dlemoal@kernel.org>
To: Yu Kuai <yukuai1@huaweicloud.com>,
axboe@kernel.dk, hare@suse.de, hch@infradead.org,
yukuai3@huawei.com, john.g.garry@oracle.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@redhat.com, calvin@wbinvd.org, david@fromorbit.com,
yi.zhang@huawei.com, yangerkun@huawei.com,
johnny.chenyi@huawei.com
Subject: Re: [PATCH] block: fix false warning in bdev_count_inflight_rw()
Date: Thu, 26 Jun 2025 17:54:40 +0900 [thread overview]
Message-ID: <2350a34d-2f7b-49c0-b286-2856c088131a@kernel.org> (raw)
In-Reply-To: <20250626083927.576207-1-yukuai1@huaweicloud.com>
On 6/26/25 17:39, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> While bdev_count_inflight is interating all cpus, if some IOs are issued
> from traversed cpu and then completed from the cpu that is not traversed
> yet:
>
> cpu0
> cpu1
> bdev_count_inflight
> //for_each_possible_cpu
> // cpu0 is 0
> infliht += 0
> // issue a io
> blk_account_io_start
> // cpu0 inflight ++
>
> cpu2
> // the io is done
> blk_account_io_done
> // cpu2 inflight --
> // cpu 1 is 0
> inflight += 0
> // cpu2 is -1
> inflight += -1
> ...
>
> In this case, the total inflight will be -1, causing lots of false
> warning. Fix the problem by removing the warning.
>
> Noted there is still a valid warning for nvme-mpath(From Yi) that is not
> fixed yet.
>
> Fixes: f5482ee5edb9 ("block: WARN if bdev inflight counter is negative")
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Closes: https://lore.kernel.org/linux-block/aFtUXy-lct0WxY2w@mozart.vkv.me/T/#mae89155a5006463d0a21a4a2c35ae0034b26a339
> Reported-and-tested-by: Calvin Owens <calvin@wbinvd.org>
> Closes: https://lore.kernel.org/linux-block/aFtUXy-lct0WxY2w@mozart.vkv.me/T/#m1d935a00070bf95055d0ac84e6075158b08acaef
> Reported-by: Dave Chinner <david@fromorbit.com>
> Closes: https://lore.kernel.org/linux-block/aFuypjqCXo9-5_En@dread.disaster.area/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> block/genhd.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 8171a6bc3210..680fa717082f 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -141,9 +141,14 @@ static void bdev_count_inflight_rw(struct block_device *part,
> }
> }
>
> - if (WARN_ON_ONCE((int)inflight[READ] < 0))
> + /*
> + * While iterating all cpus, some IOs might issued from traversed cpu
> + * and then completed from the cpu that is not traversed yet, causing
> + * the inflight number to be negative.
Nit (grammar):
* While iterating all CPUs, some IOs may be issued from a CPU already
* traversed and complete on a CPU that has not yet been traversed,
* causing the inflight number to be negative.
> + */
> + if ((int)inflight[READ] < 0)
> inflight[READ] = 0;
> - if (WARN_ON_ONCE((int)inflight[WRITE] < 0))
> + if ((int)inflight[WRITE] < 0)
> inflight[WRITE] = 0;
> }
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-06-26 8:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 8:39 [PATCH] block: fix false warning in bdev_count_inflight_rw() Yu Kuai
2025-06-26 8:54 ` Damien Le Moal [this message]
2025-06-26 11:32 ` Yu Kuai
2025-06-26 9:34 ` John Garry
2025-06-26 11:37 ` Yu Kuai
2025-06-26 10:11 ` Christoph Hellwig
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=2350a34d-2f7b-49c0-b286-2856c088131a@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=calvin@wbinvd.org \
--cc=david@fromorbit.com \
--cc=hare@suse.de \
--cc=hch@infradead.org \
--cc=john.g.garry@oracle.com \
--cc=johnny.chenyi@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yi.zhang@redhat.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.