Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6096383rwr; Tue, 9 May 2023 10:08:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kRFbD9egCKVUtYx4vpfGP6P1rfNYnvfMxcnG4absRW8uaVI1KE7UqQjYQxmUeQveXnC+n X-Received: by 2002:a17:90a:ce87:b0:250:2d62:d3e2 with SMTP id g7-20020a17090ace8700b002502d62d3e2mr14568423pju.22.1683652083471; Tue, 09 May 2023 10:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683652083; cv=none; d=google.com; s=arc-20160816; b=lvm1rIV4SZIxh96ErHNA5c0XIEdBsasXzKKlPmVMHR0Brd3sd3wzrzeNnK2UtKncpN ZaGj/jfG5/vq6M3fuxBWmupFGJLMQm7MhAiDLaioB6DRzXSOeTxZAxprfTitXqBH/BW2 mq5cnfoIQS47z2/2ov4T+SrucbRkaBT0CYrbSTWqLMWFhaZpLZzO2iQju8akoENlHdmb LohprC5Tx4VJ39WV14m5xf3nv4vjVSFaajDHY2/PJDbmdOk3TjYgrtbG6YnekIwPM8M0 g0Kzo68V8vMqZJbtBlqd2ZGJPb62iuioZIupEQbXr4Q4SnVEzAfTeuKaC3FgHRW1nbt1 5SQQ== 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=5eXxZII/AY+4X/BxaYnmkLZzUciXf9EGOnTBvq8dyQQ=; b=Lp/ig8HVea4HVuW3xvNZcYvvA4DHtQdLJX9N6MPLZ+JH882D7XUEHETqArR4AR2odg Yhim76MpyRJHkuJIYhdCn1sJjkGsiitBsJT0gMWEh4yLHRPYKPZzEZlX8IZEDUMgeF7H XlaApDhLJyt2okgsjfdsG3JDtBKbuZEgOQTuHrHRAZDBGwEQECR+zyCxGdpeuDnoUFYN A7Qzxx88Ykbjvarhph4q96YgGYifvtIFuR3GANHhfZuAfqgqV3CTVPpUTxFfV3t5N0V0 hsG/Ymrlsy5E//nHaqnePJpk5wCbo8258Pr4YB0/kmaHupHXoY376JLcJs/XHJQg9gws Ho5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P3WJrYDS; 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 l2-20020a17090aec0200b0024e0758c190si20121055pjy.27.2023.05.09.10.07.50; Tue, 09 May 2023 10:08:03 -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=P3WJrYDS; 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 S235204AbjEIQ7V (ORCPT + 99 others); Tue, 9 May 2023 12:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234987AbjEIQ6V (ORCPT ); Tue, 9 May 2023 12:58:21 -0400 Received: from out-50.mta1.migadu.com (out-50.mta1.migadu.com [IPv6:2001:41d0:203:375::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60BF85FC9 for ; Tue, 9 May 2023 09:57:29 -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=1683651447; 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=5eXxZII/AY+4X/BxaYnmkLZzUciXf9EGOnTBvq8dyQQ=; b=P3WJrYDS9WYJIkDCpbnvLdDXfB2wMF192jc7g914mAZvMadSvCzAcfAvnGQgHG4ob3rALb IYQ299pn7imaicd+BdX8TMdqCyemGSuhAF+WYKm2U6bErM0UIDAwKPTKAVzlxPC7beBL3F C78AGlXiDX7tV3NvYLrZwMwpodbPG0Y= From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 18/32] closures: closure_nr_remaining() Date: Tue, 9 May 2023 12:56:43 -0400 Message-Id: <20230509165657.1735798-19-kent.overstreet@linux.dev> In-Reply-To: <20230509165657.1735798-1-kent.overstreet@linux.dev> References: <20230509165657.1735798-1-kent.overstreet@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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 Factor out a new helper, which returns the number of events outstanding. Signed-off-by: Kent Overstreet --- include/linux/closure.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/closure.h b/include/linux/closure.h index 36b4a83f9b..722a586bb2 100644 --- a/include/linux/closure.h +++ b/include/linux/closure.h @@ -172,6 +172,11 @@ void __closure_wake_up(struct closure_waitlist *list); bool closure_wait(struct closure_waitlist *list, struct closure *cl); void __closure_sync(struct closure *cl); +static inline unsigned closure_nr_remaining(struct closure *cl) +{ + return atomic_read(&cl->remaining) & CLOSURE_REMAINING_MASK; +} + /** * closure_sync - sleep until a closure a closure has nothing left to wait on * @@ -180,7 +185,7 @@ void __closure_sync(struct closure *cl); */ static inline void closure_sync(struct closure *cl) { - if ((atomic_read(&cl->remaining) & CLOSURE_REMAINING_MASK) != 1) + if (closure_nr_remaining(cl) != 1) __closure_sync(cl); } -- 2.40.1