From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D3EEC54EE9 for ; Sat, 17 Sep 2022 09:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiIQJLN (ORCPT ); Sat, 17 Sep 2022 05:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiIQJKr (ORCPT ); Sat, 17 Sep 2022 05:10:47 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C59399F0 for ; Sat, 17 Sep 2022 02:10:33 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R941e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0VQ-LTNS_1663405829; Received: from 30.39.131.12(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VQ-LTNS_1663405829) by smtp.aliyun-inc.com; Sat, 17 Sep 2022 17:10:30 +0800 Message-ID: Date: Sat, 17 Sep 2022 17:10:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] sbitmap: fix permanent io blocking caused by insufficient wakeup times To: Hillf Danton Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org References: <20220917035831.735-1-hdanton@sina.com> From: Liu Song In-Reply-To: <20220917035831.735-1-hdanton@sina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/17 11:58, Hillf Danton wrote: > On 17 Sep 2022 10:33:01 +0800 Liu Song wrote: >> @@ -632,10 +633,14 @@ static bool __sbq_wake_up(struct sbitmap_queue *sbq) >> if (ret == wait_cnt) { >> sbq_index_atomic_inc(&sbq->wake_index); >> wake_up_nr(&ws->wait, wake_batch); >> - return false; >> + if (!nr || *nr <= 0) >> + return false; >> } >> >> return true; >> + } else if (nr && *nr) { >> + (*nr)--; >> + goto again; >> } >> >> return false; > Hi Song, > > See if advancing wake_index can survive your tests. Hi Thanks for your suggestion, this problem not only needs to switch a wait queue, but also needs to consume "wait_cnt" correctly. Thanks > > Only for thoughts now. > > Hillf > --- a/lib/sbitmap.c > +++ b/lib/sbitmap.c > @@ -611,6 +611,7 @@ static bool __sbq_wake_up(struct sbitmap > if (wait_cnt <= 0) { > int ret; > > + sbq_index_atomic_inc(&sbq->wake_index); > wake_batch = READ_ONCE(sbq->wake_batch); > > /* > @@ -627,7 +628,6 @@ static bool __sbq_wake_up(struct sbitmap > */ > ret = atomic_cmpxchg(&ws->wait_cnt, wait_cnt, wake_batch); > if (ret == wait_cnt) { > - sbq_index_atomic_inc(&sbq->wake_index); > wake_up_nr(&ws->wait, wake_batch); > return false; > }