lkml.org 
[lkml]   [2017]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 02/11] refcount: Implement inc/decrement-and-return functions
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().

\
 
 \ /
  Last update: 2017-09-01 18:43    [W:0.119 / U:6.164 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site