Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9345980rwp; Thu, 20 Jul 2023 03:38:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8N+rdL5nlPiT34Dks67ya7SPuJ73mj5hVyVW6l3bRA6Ddcymsjvvse0E32C36nBa2SAZy X-Received: by 2002:a17:906:2449:b0:977:eed1:453c with SMTP id a9-20020a170906244900b00977eed1453cmr1751043ejb.73.1689849514185; Thu, 20 Jul 2023 03:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689849514; cv=none; d=google.com; s=arc-20160816; b=Wb9dRLkEdK+teWYZOKHcMLO6jUIuX0Eu2G7/6yi9z2P2lyrgdmqGpQrLhpNb5tkMaN EhtqHfaMMiXfehwazGwu2ddMjBpmbnnN3jaFqUmsdMN4hiXzC2YRXbpqNzBSZBw7cvwL xxsrcfCzKF+qHY1o7oOXEb9e94HWzkoZ9eJhv+71qwBy4eSpWKTNT9ntGPpc7Irl6Lcp GZ/nd02k7r/AEmZPyxP9oOd4Pb1hUPCBH/iO1cfF8ls39C9el6qSXG1BwgcquEaWPcJJ nQAUrzb+fNKCC7zpbpnynH+OETH72qErHZ2VjH5waEqEsMm/M2lU5Z3Ajd+ZboRf6TNE KT3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iYyPqspkOuXVMavHO7B8mxFBAqzpe8Xduz/Ay3699EE=; fh=hjJkBnU2szufEu6iYNeHw5+ILtjbq+a6zNGIo+CbvPw=; b=Yztyb9bwBKuGvfNd67XiUoxtaWRpVijJ5Oa+JPB0iK2EsXFwHO2X30U1hGpwtyw2xz 6u7Pbm7rUC3+vklPb6DRU/YMVX2Mar60XtA3dxoTmT+VxEdEc7HxK+KMQeA9bF6KPd9j UYoAj2LOLewQzmZutkNq8NoJNPuG6iQhycswC0XpUsuSnhzfHuGkvmq2118JxvzqN9FG wBlKAqxz3QHZat7Cm9kTb466bjDLdVEY6J1hC3OdDELKAL/82iVUaJsRK0Su3sFOAqnB 4KLmNnMfI5DoZI1vrtm8XEWPuJgzJVcGXAB60gXZSRfpybt+IdNt/m58UVHeIFvejtGJ tk1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pw5sQb18; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a1709066b8e00b00982a267a399si478181ejr.561.2023.07.20.03.38.09; Thu, 20 Jul 2023 03:38:34 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b=pw5sQb18; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjGTJtw (ORCPT + 99 others); Thu, 20 Jul 2023 05:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjGTJt1 (ORCPT ); Thu, 20 Jul 2023 05:49:27 -0400 Received: from out-34.mta0.migadu.com (out-34.mta0.migadu.com [91.218.175.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83E1189 for ; Thu, 20 Jul 2023 02:47:42 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689846460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iYyPqspkOuXVMavHO7B8mxFBAqzpe8Xduz/Ay3699EE=; b=pw5sQb18kA//kymlNb+qvXIDo6jCV6+mmT0zU6VFQozPJNN8PoBdLacoMJrd/1FqdpJvcW VwuVolXq85zUUtFfX40ZQSiEGTsPAgEbohducF49YxBq9Q/Wf59Odv9Bl0BlUS6IqohIJQ /iml5vko4ls+yXcePH2pF7w/oW2Of3U= From: chengming.zhou@linux.dev To: axboe@kernel.dk, osandov@fb.com, ming.lei@redhat.com, kbusch@kernel.org, krisman@suse.de Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH 6/6] sbitmap: check ws_active before check waitqueues Date: Thu, 20 Jul 2023 17:45:55 +0800 Message-ID: <20230720094555.1397621-7-chengming.zhou@linux.dev> In-Reply-To: <20230720094555.1397621-1-chengming.zhou@linux.dev> References: <20230720094555.1397621-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Chengming Zhou When !ws_active, we don't need to check waitqueues at all. So add this check in sbitmap_queue_wake_all(), like we do in sbitmap_queue_wake_up(). Signed-off-by: Chengming Zhou --- lib/sbitmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 6778ab3fc6a5..38c265e4ef9d 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -672,6 +672,10 @@ void sbitmap_queue_wake_all(struct sbitmap_queue *sbq) * sbitmap_queue_wake_up(). */ smp_mb(); + + if (!atomic_read(&sbq->ws_active)) + return; + wake_index = READ_ONCE(sbq->wake_index); for (i = 0; i < SBQ_WAIT_QUEUES; i++) { struct sbq_wait_state *ws = &sbq->ws[wake_index]; -- 2.41.0