Re: [RFC PATCH 02/11] refcount: Implement inc/decrement-and-return functions

From: Christoph Hellwig
Date: Mon Sep 04 2017 - 11:37:02 EST


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)