Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3746210pxb; Tue, 26 Jan 2021 03:47:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7P4UZ01FSiJfgSVPVUphYT3axs0OEwt/HJwMv1BpZtHqXJJ3lSCmYgKvrkg0mmO4tgylU X-Received: by 2002:a17:906:a445:: with SMTP id cb5mr3264942ejb.0.1611661627763; Tue, 26 Jan 2021 03:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611661627; cv=none; d=google.com; s=arc-20160816; b=HIG1PgSwcpmVOVCQ0DcMwWO2akZgGGqio3Itn8BH9TwnoJnbUwwTMl84A+lCjjTfkE PlBD9vUZzDr9XXpflyU0C4RZPlyaO2HBs5gGnTCUv+W5MuAggcvV54d7vEb2/FpCRV2R tFonJCpFTu3bnfZBnrrFPMlDU0SClXLy7n58rlrkp1wthOBFLR9iZuAHldZey+JnVBDe uVR8N4TSpKcE9aLxNpfvDCVAtuK1JGUwRcCKXH6Vrvdu+cqeYmLZqJl1DpEers5wMQUi RyOHWgDNoeS6uFDZzul968Xi91n/9uEecJ3x023gTe98iS9VswOaJkhqggvbRgAr1xGX /yTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=B7xj1vVc4HNNMNiCYZvylA2+cbCnK0udL5Jus77CY5w=; b=DKc25QvVPklEQXgJzSt+A4Sg6DmXZYcIv9llnLlNmZwcTVcP1x2R0OA/H9ThVNPXPR W3Mc2pb9JKhas3wPeOdLhYkAjqVFonBwlGvIXcVs6krKBTAKploJbzaKrS43IGOEit6B Mgq0rTT7rex3Iu0ZFHUZ++TeAdEsZBulT9bM0beTg0k3qs1zGydVk3Lwirz91qN743DH 1C1ajZPdtemgKJLJV//ZP5wu1gOTLfUfe2jmITczibAQlERvmQYkfniZmcf+UA7gnwHW eG+HhLmunvF/MQSVk8wQAd37yDIzZletivKWgEx9Fm0sWf63G9rODuFgv3OLqvqg3xC4 OzTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dvm9ZTjR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si5526993edy.263.2021.01.26.03.46.43; Tue, 26 Jan 2021 03:47:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dvm9ZTjR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392508AbhAZLp6 (ORCPT + 99 others); Tue, 26 Jan 2021 06:45:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39495 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403782AbhAZL1P (ORCPT ); Tue, 26 Jan 2021 06:27:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611660349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B7xj1vVc4HNNMNiCYZvylA2+cbCnK0udL5Jus77CY5w=; b=Dvm9ZTjRiK7EPxNyRb2OOKjVgqtgqzV8jHDfKaOBWA5eBX2k2V2rpGssQMzgkupMJkqogO ddh96BLOOPc9BA7Y4hVD+MmWKoq4XwKeMNXiDdV0wlEZiQHRG/Xpm9WwdkSqemM9y35QUS kPNBUbmBg7KfeWnwQp62eIygSqTpZCI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-k2dwZpoEMeOE1nsI7jRpkw-1; Tue, 26 Jan 2021 06:25:46 -0500 X-MC-Unique: k2dwZpoEMeOE1nsI7jRpkw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3D0E107ACE3; Tue, 26 Jan 2021 11:25:43 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-115-23.rdu2.redhat.com [10.10.115.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 778AB62950; Tue, 26 Jan 2021 11:25:40 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20200921112218.GB2139@willie-the-truck> References: <20200921112218.GB2139@willie-the-truck> <20200721195132.GJ10769@hirez.programming.kicks-ass.net> <202006142054.C00B3E9C9@keescook> <20200612183450.4189588-1-keescook@chromium.org> <7be4d56b-0406-099b-e505-02e074c5173e@huawei.com> <544539.1595328664@warthog.procyon.org.uk> <202007211144.A68C31D@keescook> <3211866.1595933798@warthog.procyon.org.uk> <20200729111120.GA2638@hirez.programming.kicks-ass.net> To: Will Deacon Cc: dhowells@redhat.com, peterz@infradead.org, Kees Cook , Xiaoming Ni , David Windsor , Hans Liljestrand , Elena Reshetova , Paul Moore , edumazet@google.com, paulmck@kernel.org, shakeelb@google.com, James Morris , alex.huangjianhui@huawei.com, dylix.dailei@huawei.com, chenzefeng2@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] locking/refcount: Provide __refcount API to obtain the old value MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2697075.1611660339.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 26 Jan 2021 11:25:39 +0000 Message-ID: <2697076.1611660339@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Will Deacon wrote: > > @@ -219,9 +235,14 @@ static inline void refcount_add(int i, r > > * > > * Return: true if the increment was successful, false otherwise > > */ > > +static inline __must_check bool __refcount_inc_not_zero(refcount_t *r= , int *oldp) > > +{ > > + return __refcount_add_not_zero(1, r, oldp); > > +} > = > Where returning both a bool to indicate whether the old value was zero > and also the old value itself is a bit OTT. Actually, with the i386 cmpxchg, that makes sense. You can use the Z flag= to give you the bool, saving on checking the old value. David