From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752465AbdIAQmn (ORCPT ); Fri, 1 Sep 2017 12:42:43 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56782 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752198AbdIAQml (ORCPT ); Fri, 1 Sep 2017 12:42:41 -0400 Date: Fri, 1 Sep 2017 18:42:33 +0200 From: Peter Zijlstra To: David Howells Cc: linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 02/11] refcount: Implement inc/decrement-and-return functions Message-ID: <20170901164233.wu4fdljpivzf5idb@hirez.programming.kicks-ass.net> References: <150428045304.25051.1778333106306853298.stgit@warthog.procyon.org.uk> <150428046185.25051.3518486828049323804.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <150428046185.25051.3518486828049323804.stgit@warthog.procyon.org.uk> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 01, 2017 at 04:41:01PM +0100, David Howells wrote: > Implement functions that increment or decrement a refcount_t object and > return the value. The dec-and-ret function can be used to maintain a > counter in a cache where 1 means the object is unused, but available and > the garbage collector can use refcount_dec_if_one() to make the object > unavailable. Further, both functions can be used to accurately trace the > refcount (refcount_inc() followed by refcount_read() can't be considered > accurate). > > The interface is as follows: > > unsigned int refcount_dec_return(refcount_t *r); > unsigned int refcount_inc_return(refcount_t *r); > I'm not immediately seeing how wanting 1 to mean unused leads to requiring these two functions. If you'll remember, I did that for inode_count and only needed dec_unless().