Re: [RFC] kref, a tiny, sane, reference count object

From: Nick Piggin
Date: Sat Mar 13 2004 - 23:23:24 EST

Andrew Morton wrote:

Nick Piggin <piggin@xxxxxxxxxxxxxxx> wrote:

Andrew Morton wrote:

Greg KH <greg@xxxxxxxxx> wrote:

For all of those people, this patch is for you.

It does rather neatly capture a common idiom.

But as Andi said - look at all the crap involved when:

if (atomic_dec_and_test())
Also neatly captures that idiom.

Well it does more than that, such as trapping the hard-to-diagnose bug
of grabbing a refcount against a zero-ref object.

And you get more flexibility by being able to use atomic_set
directly too.

Do I care about that? I care more about being able to say "ah, it uses
kref. I understand that refcounting idiom, I know it's well debugged and I
know that it traps common errors". That's better than "oh crap, this thing
implements its own refcounting - I need to review it for the usual

OK good point.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at