Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp689472rdf; Fri, 3 Nov 2023 11:56:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmubqDI5OZipONYn412B1UagqaOTTFgp56fSSEqKXSDRlzAhRsqhCR7A4QcQHCBguYuaB1 X-Received: by 2002:a17:902:b783:b0:1c9:b207:d40b with SMTP id e3-20020a170902b78300b001c9b207d40bmr19584062pls.38.1699037783823; Fri, 03 Nov 2023 11:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699037783; cv=none; d=google.com; s=arc-20160816; b=J0KSkCLdZ+prG3MHwaz6u3NAZgJZXTqf1F3irDo7wWOZMgzXrlutX79oLHzTse2lf5 6aDhfmTJ3IdO3uXKUUN1a5AIrAmNZ6Bqyy5fjuxaF+0UP6puuDUIn3PrCs3FiHi9I8Zb BN2GVEJ4Iy48ZmUFtmN1NnyaMax9mcHP0+NxIh7Q8NrUdIQ+hFrGmQT/7LNi8N3UTJpc 7qmKLn+Jd7KfHItKboK23lBoRwSNDQekRK+2ksaq/V6Dw3HRXnawCxLvrZ9GQ5k+ggd6 bDT52BycknivtVb8a0vEE6B9i49LZ6l7cj3i/JOtFfakWuVw4AlQyL/BvjBnjvbD17Kh uC6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lMSyzAFDVyohiximkrZHfefmepkkBFb8l8Zpm/xuQW0=; fh=X0LGzr67zCQH0xRo8jBd0aRLVwLoUVKGnFTmrBMm5C8=; b=K3F70N4AdQmedOsncvSPVkmz9NShWg4fmuisESQE7X1tQaJ2TIiCxFiINp5YsDYhZx Gw/s6eod9TU6LJn5OFZ97u+p/NFNLbnlY2I2ZSEqE4z3DjVvfsAQ7k+Cc9GZc8gEKCDk DJcVHzOqtHjzoRMFBhBHcJmnPRjDLcNmkZQZg/p522Y0uEZLKJPF0YJin3nykk7WSkUs zpySa+ZHvNHG2DS25GEnhMzp1OnV4+uepvu6XNyncAMFydjOx2h+2tPXZk1GEWo45y3p az108sDaObkewbGwrWbdp+D/lo7RH4A7+wjE3MCf1F5j/ZHp0Sep6rqPN2hHtZoDT+wL gq2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aBiC7Rrq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f6-20020a170902ce8600b001cc4b3d1a90si2084679plg.479.2023.11.03.11.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 11:56:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aBiC7Rrq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9133383B2E2F; Fri, 3 Nov 2023 11:55:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345518AbjKCSyg (ORCPT + 99 others); Fri, 3 Nov 2023 14:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjKCSyf (ORCPT ); Fri, 3 Nov 2023 14:54:35 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F3DBD for ; Fri, 3 Nov 2023 11:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=lMSyzAFDVyohiximkrZHfefmepkkBFb8l8Zpm/xuQW0=; b=aBiC7RrqRLj9aeyNctrnxAhJz2 JhuwjmOJ8SNazej8roFiWvPrtxnEU3ooqFV3wC1eO31jJEKwswJ3MiQzzCdqqQ2xrYguU+9gK2NaS EOJSW/RH961k0PKWsMc6LhwB98k41RIvvtvMc2wPbX+d/zO5RVAoePn4W94Mb3NW4lxcWbQ0l0UJt +kS25qjCbb8TO/bZuRiHD+zSAcO70u2GInU/85N+W5U+XQgOke87mRA1kZvsysXNN/wcUT7A3pxDY IVF/6LaqDFEEo8QvL23WArw1EidQXgtYBN+ES/lmhC6PdKfAtHvoar1YRacJIR0pm5loopID8qLLt kshUJVIA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qyzJ7-006znm-Ph; Fri, 03 Nov 2023 18:54:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 25D403002AF; Fri, 3 Nov 2023 19:54:14 +0100 (CET) Date: Fri, 3 Nov 2023 19:54:14 +0100 From: Peter Zijlstra To: Alexander Aring Cc: will@kernel.org, gfs2@lists.linux.dev, boqun.feng@gmail.com, mark.rutland@arm.com, linux-kernel@vger.kernel.org Subject: Re: [RFC 1/2] refcount: introduce generic lockptr funcs Message-ID: <20231103185414.GD8262@noisy.programming.kicks-ass.net> References: <20231103161635.1902667-1-aahringo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231103161635.1902667-1-aahringo@redhat.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 11:55:49 -0700 (PDT) On Fri, Nov 03, 2023 at 12:16:34PM -0400, Alexander Aring wrote: > diff --git a/lib/refcount.c b/lib/refcount.c > index a207a8f22b3c..e28678f0f473 100644 > --- a/lib/refcount.c > +++ b/lib/refcount.c > @@ -94,6 +94,34 @@ bool refcount_dec_not_one(refcount_t *r) > } > EXPORT_SYMBOL(refcount_dec_not_one); > > +bool refcount_dec_and_lockptr(refcount_t *r, void (*lock)(void *lockptr), > + void (*unlock)(void *lockptr), void *lockptr) > +{ > + if (refcount_dec_not_one(r)) > + return false; > + > + lock(lockptr); > + if (!refcount_dec_and_test(r)) { > + unlock(lockptr); > + return false; > + } > + > + return true; > +} > +EXPORT_SYMBOL(refcount_dec_and_lockptr); This is terrible, you're forcing indirect calls on everything.