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@xxxxxxxxxx> > --- > 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