linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Xiao Ni <xni@redhat.com>
Cc: song@kernel.org, linux-raid@vger.kernel.org, ncroxon@redhat.com,
	heinzm@redhat.com, ming.lei@redhat.com
Subject: Re: [PATCH 2/2] md: Change active_io to percpu
Date: Tue, 31 Jan 2023 10:46:51 +0800	[thread overview]
Message-ID: <Y9iBG7GhXhJMAJP5@T590> (raw)
In-Reply-To: <20230121013937.97576-3-xni@redhat.com>

On Sat, Jan 21, 2023 at 09:39:37AM +0800, Xiao Ni wrote:
> Now the type of active_io is atomic. It's used to count how many ios are
> in the submitting process and it's added and decreased very time. But it
> only needs to check if it's zero when suspending the raid. So we can
> switch atomic to percpu to improve the performance.
> 
> After switching active_io to percpu type, we use the state of active_io
> to judge if the raid device is suspended. And we don't need to wake up
> ->sb_wait in md_handle_request anymore. It's done in the callback function
> which is registered when initing active_io. The argument mddev->suspended
> is only used to count how many users are trying to set raid to suspend
> state.
> 
> Signed-off-by: Xiao Ni <xni@redhat.com>
> ---
>  drivers/md/md.c | 40 ++++++++++++++++++++++++----------------
>  drivers/md/md.h |  2 +-
>  2 files changed, 25 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index d3627aad981a..04c067cf2f53 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -382,10 +382,7 @@ static DEFINE_SPINLOCK(all_mddevs_lock);
>  
>  static bool is_md_suspended(struct mddev *mddev)
>  {
> -	if (mddev->suspended)
> -		return true;
> -	else
> -		return false;
> +	return percpu_ref_is_dying(&mddev->active_io);
>  }
>  /* Rather than calling directly into the personality make_request function,
>   * IO requests come here first so that we can check if the device is
> @@ -412,7 +409,6 @@ static bool is_suspended(struct mddev *mddev, struct bio *bio)
>  void md_handle_request(struct mddev *mddev, struct bio *bio)
>  {
>  check_suspended:
> -	rcu_read_lock();
>  	if (is_suspended(mddev, bio)) {
>  		DEFINE_WAIT(__wait);
>  		/* Bail out if REQ_NOWAIT is set for the bio */
> @@ -432,17 +428,15 @@ void md_handle_request(struct mddev *mddev, struct bio *bio)
>  		}
>  		finish_wait(&mddev->sb_wait, &__wait);
>  	}

Hi Xiao,

All rcu_read_unlock/rcu_read_lock should be removed from the above
branch, and that could cause the ktest robot warning.

Thanks,
Ming


      parent reply	other threads:[~2023-01-31  2:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21  1:39 [PATCH 0/2] md: Change active_io to percpu Xiao Ni
2023-01-21  1:39 ` [PATCH 1/2] md: Factor out is_md_suspended helper Xiao Ni
2023-01-23 13:18   ` Paul Menzel
2023-01-23 23:48     ` Xiao Ni
2023-01-21  1:39 ` [PATCH 2/2] md: Change active_io to percpu Xiao Ni
2023-01-23 13:22   ` Paul Menzel
2023-01-23 23:50     ` Xiao Ni
2023-01-31  2:46   ` Ming Lei [this message]

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=Y9iBG7GhXhJMAJP5@T590 \
    --to=ming.lei@redhat.com \
    --cc=heinzm@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=ncroxon@redhat.com \
    --cc=song@kernel.org \
    --cc=xni@redhat.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).