From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753870AbdIDQId (ORCPT ); Mon, 4 Sep 2017 12:08:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46178 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753764AbdIDQIc (ORCPT ); Mon, 4 Sep 2017 12:08:32 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CC4074704E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dhowells@redhat.com 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: <20170904153654.GA4145@infradead.org> References: <20170904153654.GA4145@infradead.org> <150428045304.25051.1778333106306853298.stgit@warthog.procyon.org.uk> <150428046185.25051.3518486828049323804.stgit@warthog.procyon.org.uk> To: Christoph Hellwig Cc: dhowells@redhat.com, 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30457.1504541309.1@warthog.procyon.org.uk> Date: Mon, 04 Sep 2017 17:08:29 +0100 Message-ID: <30458.1504541309@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 04 Sep 2017 16:08:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christoph Hellwig 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) Which bit are you objecting to? Wanting to use a refcount_t with 1 to represent an otherwise-unreferenced object sat in a cache? Or wanting to display accurate usage counts when tracing gets and puts of objects? David