Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp135042rwb; Sat, 17 Sep 2022 02:19:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qNCRvIKMC2xNBnG4A83nR8J2Wh5flkwVOaG2O2GkkQ6YmTKEXXknIwmj797ZBvnxaonjN X-Received: by 2002:a17:907:7601:b0:73d:9f0b:d99f with SMTP id jx1-20020a170907760100b0073d9f0bd99fmr5998936ejc.300.1663406379761; Sat, 17 Sep 2022 02:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663406379; cv=none; d=google.com; s=arc-20160816; b=ToX7XtbFtNhpLTJAcZuI6ex1Dktz6Ym+ZwVyryqoetjuCVDWI10Tom7tqxhtsldlVM oxO3TjypDz0sCANHe94kJ+cLzk5B/eZddpC/nZY6neC5OjKCdRwCLvbAnqcTym+67UxZ ++rs2HP+XZaV5FELEy3lWSAPczU8Ni8STvdBPbsJbPputocHmw07IZbiy5SnmnTruOeY Ph6N5Cp1iigul7kxbGFKLwLBhkObIDZRDTeq4He7LGswrZreUMQK8yb6VzcsWTTMg9Sl Itf3LzE1bYGRoPXCzqHjvfT2wZEorZbviExLWhv1/99aLLOAY9TJzJ+RCGliKKu+VAJm x9Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=EhwdzWipao0HLEaWb253S7Hjh5QEUceI0S0jf+Ir9es=; b=vz3u+29dSzrdMloir9aDeygqLudBij7/gcnoLyW3EZ/vgaz2+ZuvV8XviEbhPzmNuP GkYVQPs78PGClge5VjstlN2C9v890JFU7iWsVgLoGkZVWR3FrLuS+IeFArh5uSLDDGdQ uHyJpv9t6vegRfvrq1XfrRaFBJuLSs8C51B3rog3q+C+6vJsHt5Djo9iqL/fYpXuC/fI mYIhx5WwVa2zQ+PijFcn1ddL4eCIxvyRUHHj6AiAXrmce10dvWD9fqCBzq6csRmrRn6V dn2akwDwOR1SwWqTYkML548ZsP9/6l6H1j9GYcxe03rkrjPRhLkgYncHNpHQ92gEVXyT +aZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oq19-20020a170906cc9300b00780dd2b1fb3si996017ejb.867.2022.09.17.02.19.11; Sat, 17 Sep 2022 02:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbiIQJLL (ORCPT + 99 others); Sat, 17 Sep 2022 05:11:11 -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 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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; > }