From: Logan Gunthorpe <logang@deltatee.com>
To: Yu Kuai <yukuai1@huaweicloud.com>,
song@kernel.org, guoqing.jiang@linux.dev, pmenzel@molgen.mpg.de
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai3@huawei.com, yi.zhang@huawei.com
Subject: Re: [PATCH v2 1/4] md/raid10: cleanup wait_barrier()
Date: Wed, 14 Sep 2022 10:16:31 -0600 [thread overview]
Message-ID: <f0dd9208-05ec-b2fa-4b29-5fa140486fa3@deltatee.com> (raw)
In-Reply-To: <20220914014914.398712-2-yukuai1@huaweicloud.com>
On 2022-09-13 19:49, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Currently the nasty condition is wait_barrier() is hard to read. This
> patch factor out the condition into a function.
>
> There are no functional changes.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/md/raid10.c | 56 ++++++++++++++++++++++++++-------------------
> 1 file changed, 32 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 64d6e4cd8a3a..56458a53043d 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -957,44 +957,52 @@ static void lower_barrier(struct r10conf *conf)
> wake_up(&conf->wait_barrier);
> }
>
> +static bool stop_waiting_barrier(struct r10conf *conf)
> +{
> + /* barrier is dropped */
> + if (!conf->barrier)
> + return true;
> +
> + /*
> + * If there are already pending requests (preventing the barrier from
> + * rising completely), and the pre-process bio queue isn't empty, then
> + * don't wait, as we need to empty that queue to get the nr_pending
> + * count down.
> + */
> + if (atomic_read(&conf->nr_pending)) {
> + struct bio_list *bio_list = current->bio_list;
I'd probably just put the bio_list declaration at the top of this
function, then the nested if statements are not necessary. The compiler
should be able to optimize the access just fine.
> if (conf->barrier) {
> - struct bio_list *bio_list = current->bio_list;
> - conf->nr_waiting++;
> - /* Wait for the barrier to drop.
> - * However if there are already pending
> - * requests (preventing the barrier from
> - * rising completely), and the
> - * pre-process bio queue isn't empty,
> - * then don't wait, as we need to empty
> - * that queue to get the nr_pending
> - * count down.
> - */
> /* Return false when nowait flag is set */
> if (nowait) {
> ret = false;
> } else {
> + conf->nr_waiting++;
Technically speaking, I think moving nr_waiting counts as a functional
change. As best as I can see it is correct, but it should probably be at
least mentioned in the commit message, or maybe done as a separate
commit with it's own justification. That way if it causes problems down
the road, a bisect will make the issue clearer.
Thanks,
Logan
next prev parent reply other threads:[~2022-09-14 16:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 1:49 [PATCH v2 0/4] md/raid10: reduce lock contention for io Yu Kuai
2022-09-14 1:49 ` [PATCH v2 1/4] md/raid10: cleanup wait_barrier() Yu Kuai
2022-09-14 6:36 ` Paul Menzel
2022-09-14 10:28 ` Yu Kuai
2022-09-14 16:16 ` Logan Gunthorpe [this message]
2022-09-15 7:21 ` Yu Kuai
2022-09-15 9:12 ` Paul Menzel
2022-09-14 1:49 ` [PATCH v2 2/4] md/raid10: prevent unnecessary calls to wake_up() in fast path Yu Kuai
2022-09-14 10:21 ` Yu Kuai
2022-09-14 1:49 ` [PATCH v2 3/4] md/raid10: fix improper BUG_ON() in raise_barrier() Yu Kuai
2022-09-14 1:49 ` [PATCH v2 4/4] md/raid10: convert resync_lock to use seqlock Yu Kuai
2022-09-14 10:26 ` Yu Kuai
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=f0dd9208-05ec-b2fa-4b29-5fa140486fa3@deltatee.com \
--to=logang@deltatee.com \
--cc=guoqing.jiang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=pmenzel@molgen.mpg.de \
--cc=song@kernel.org \
--cc=yi.zhang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox