Re: [RFC][PATCH 7/7] kref: Implement using refcount_t

From: Peter Zijlstra
Date: Thu Nov 17 2016 - 12:06:06 EST


On Thu, Nov 17, 2016 at 12:03:33PM +0100, Greg KH wrote:
> On Thu, Nov 17, 2016 at 11:39:27AM +0100, Peter Zijlstra wrote:

> > And let me note here that RCU users can use a fully relaxed put, because
> > call_rcu() guarantees a grace-period between the call_rcu and the
> > free(), which in turn provides a full memory barrier that orders things.
> >
> > We could actually expose that to driver writers by doing something like:
> >
> > kref_put_rcu(struct kref *kref, struct rcu_head *head, rcu_callback_t func)
> > {
> > if (refcount_dec_and_test_relaxed(&kref->refcount))
> > call_rcu(head, func);
> > }
> >
> > Do we want to go there?
>
> No, please no...

Hehe, fair enough. Although core kernel 'power' users might really want
that. The relaxed memory order stuff saves quite a few cycles on weak
archs.