RE: [RFC][PATCH 2/7] kref: Add kref_read()

From: Reshetova, Elena
Date: Mon Nov 21 2016 - 10:39:26 EST

> By the way, there are several sites where the use of
> atomic_t/atomic_wrap_t as a counter ventures beyond the standard (inc,
> dec, add, sub, read, set) operations we're planning on implementing
> for both refcount_t and stats_t.

Speaking of non-fitting patterns. This one is quite common in networking code for refcounters:

if (atomic_cmpxchg(&cur->refcnt, 1, 0) == 1) {}
This is from net/netfilter/nfnetlink_acct.c, but there are similar ones in other places.

Also, simple atomic_dec() is used pretty much everywhere for counters, which we donât have a straight match in refcount_t API.