linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: Yu Kuai <yukuai1@huaweicloud.com>,
	song@kernel.org, logang@deltatee.com, 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 v3 3/5] md/raid10: prevent unnecessary calls to wake_up() in fast path
Date: Sun, 18 Sep 2022 19:38:50 +0800	[thread overview]
Message-ID: <5f2b0c5d-209b-9c0c-ff22-781542d5517e@linux.dev> (raw)
In-Reply-To: <20220916113428.774061-4-yukuai1@huaweicloud.com>



On 9/16/22 7:34 PM, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Currently, wake_up() is called unconditionally in fast path such as
> raid10_make_request(), which will cause lock contention under high
> concurrency:
>
> raid10_make_request
>   wake_up
>    __wake_up_common_lock
>     spin_lock_irqsave
>
> Improve performance by only call wake_up() if waitqueue is not empty
> in allow_barrier() and raid10_make_request().
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/raid10.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index df435d693637..cf452c25e1e5 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -274,6 +274,12 @@ static void put_buf(struct r10bio *r10_bio)
>   	lower_barrier(conf);
>   }
>   
> +static void wake_up_barrier(struct r10conf *conf)
> +{
> +	if (wq_has_sleeper(&conf->wait_barrier))
> +		wake_up(&conf->wait_barrier);
> +}
> +
>   static void reschedule_retry(struct r10bio *r10_bio)
>   {
>   	unsigned long flags;
> @@ -1015,7 +1021,7 @@ static void allow_barrier(struct r10conf *conf)
>   {
>   	if ((atomic_dec_and_test(&conf->nr_pending)) ||
>   			(conf->array_freeze_pending))
> -		wake_up(&conf->wait_barrier);
> +		wake_up_barrier(conf);
>   }
>   
>   static void freeze_array(struct r10conf *conf, int extra)
> @@ -1891,7 +1897,7 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio)
>   	__make_request(mddev, bio, sectors);
>   
>   	/* In case raid10d snuck in to freeze_array */
> -	wake_up(&conf->wait_barrier);
> +	wake_up_barrier(conf);
>   	return true;
>   }
>   

Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Thanks,
Guoqing

  parent reply	other threads:[~2022-09-18 11:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 11:34 [PATCH v3 0/5] md/raid10: reduce lock contention for io Yu Kuai
2022-09-16 11:34 ` [PATCH v3 1/5] md/raid10: factor out code from wait_barrier() to stop_waiting_barrier() Yu Kuai
2022-09-16 18:35   ` Logan Gunthorpe
2022-09-18 11:40   ` Guoqing Jiang
2022-09-16 11:34 ` [PATCH v3 2/5] md/raid10: don't modify 'nr_waitng' in wait_barrier() for the case nowait Yu Kuai
2022-09-16 18:35   ` Logan Gunthorpe
2022-09-18 11:40   ` Guoqing Jiang
2022-09-16 11:34 ` [PATCH v3 3/5] md/raid10: prevent unnecessary calls to wake_up() in fast path Yu Kuai
2022-09-16 18:36   ` Logan Gunthorpe
2022-09-18 11:38   ` Guoqing Jiang [this message]
2022-09-16 11:34 ` [PATCH v3 4/5] md/raid10: fix improper BUG_ON() in raise_barrier() Yu Kuai
2022-09-16 18:36   ` Logan Gunthorpe
2022-09-18 11:37   ` Guoqing Jiang
2022-09-16 11:34 ` [PATCH v3 5/5] md/raid10: convert resync_lock to use seqlock Yu Kuai
2022-09-16 18:37   ` Logan Gunthorpe
2022-09-18 11:36   ` Guoqing Jiang
2022-09-19  1:08     ` Yu Kuai
2022-09-19 10:28       ` Guoqing Jiang
2022-09-19 19:08         ` Song Liu

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=5f2b0c5d-209b-9c0c-ff22-781542d5517e@linux.dev \
    --to=guoqing.jiang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=logang@deltatee.com \
    --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;
as well as URLs for NNTP newsgroup(s).