From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753847AbdIDPg5 (ORCPT ); Mon, 4 Sep 2017 11:36:57 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:47914 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753735AbdIDPg4 (ORCPT ); Mon, 4 Sep 2017 11:36:56 -0400 Date: Mon, 4 Sep 2017 08:36:54 -0700 From: Christoph Hellwig To: David Howells Cc: linux-afs@lists.infradead.org, Peter Zijlstra , 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: <20170904153654.GA4145@infradead.org> 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: Mutt/1.8.3 (2017-05-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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). Please just use a different interface for that instead of overloading refcount_t. The main use case of that type is that it is so simple that it is hard to get wrong (and have additional checking if things go wrong)