public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Hugh Dickins <hughd@google.com>
Cc: Jens Axboe <axboe@kernel.dk>, Yu Kuai <yukuai1@huaweicloud.com>,
	Jan Kara <jack@suse.cz>, Liu Song <liusong@linux.alibaba.com>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH next] sbitmap: fix lockup while swapping
Date: Mon, 19 Sep 2022 15:22:16 -0600	[thread overview]
Message-ID: <YyjdiKC0YYUkI+AI@kbusch-mbp> (raw)
In-Reply-To: <aef9de29-e9f5-259a-f8be-12d1b734e72@google.com>

On Sun, Sep 18, 2022 at 02:10:51PM -0700, Hugh Dickins wrote:
> I have almost no grasp of all the possible sbitmap races, and their
> consequences: but using the same !waitqueue_active() check as used
> elsewhere, fixes the lockup and shows no adverse consequence for me.

 
> Fixes: 4acb83417cad ("sbitmap: fix batched wait_cnt accounting")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> 
>  lib/sbitmap.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/lib/sbitmap.c
> +++ b/lib/sbitmap.c
> @@ -620,7 +620,7 @@ static bool __sbq_wake_up(struct sbitmap
>  		 * function again to wakeup a new batch on a different 'ws'.
>  		 */
>  		if (cur == 0)
> -			return true;
> +			return !waitqueue_active(&ws->wait);

If it's 0, that is supposed to mean another thread is about to make it not zero
as well as increment the wakestate index. That should be happening after patch
48c033314f37 was included, at least.

Prior to 4acb83417cad, the code would also return 'true' if the count was
already zero, and this batched code wasn't supposed to behave any different in
that condition.

Anyway, I don't think the waitqueue_active criteria of the current waitstate is
correct either. The next waitstate may have waiters too, so we still may need
to account for this batch's count in order to wake them.

  reply	other threads:[~2022-09-19 21:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 21:10 [PATCH next] sbitmap: fix lockup while swapping Hugh Dickins
2022-09-19 21:22 ` Keith Busch [this message]
2022-09-19 23:01   ` Hugh Dickins
2022-09-21 16:40     ` Jan Kara
2022-09-23 14:43       ` Jan Kara
2022-09-23 15:13         ` Keith Busch
2022-09-23 16:16         ` Hugh Dickins
2022-09-23 19:07           ` Keith Busch
2022-09-23 21:29             ` Hugh Dickins
2022-09-23 23:15               ` Hugh Dickins
2022-09-26 11:44                 ` Jan Kara
2022-09-26 14:08                   ` Yu Kuai
2022-09-27  3:39                   ` Hugh Dickins
2022-09-27 10:31                     ` Jan Kara
2022-09-28  3:56                       ` Hugh Dickins
2022-09-28  3:59                         ` [PATCH next v2] " Hugh Dickins
2022-09-28  4:07                           ` Hugh Dickins
2022-09-29  8:39                             ` Jan Kara
2022-09-29 19:50                               ` [PATCH next v3] " Hugh Dickins
2022-09-29 19:56                                 ` Keith Busch
2022-09-29 23:58                                 ` Jens Axboe
     [not found]               ` <20220924023047.1410-1-hdanton@sina.com>
2022-09-27  4:02                 ` [PATCH next] " Hugh Dickins

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=YyjdiKC0YYUkI+AI@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liusong@linux.alibaba.com \
    --cc=yukuai1@huaweicloud.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