User: Password:
|
|
Subscribe / Log in / New account

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

From:  Andrew Morton <akpm-AT-osdl.org>
To:  Nick Piggin <piggin-AT-cyberone.com.au>
Subject:  Re: [RFC] kref, a tiny, sane, reference count object
Date:  Sat, 13 Mar 2004 20:10:17 -0800
Cc:  greg-AT-kroah.com, linux-kernel-AT-vger.kernel.org, ak-AT-suse.de

Nick Piggin <piggin@cyberone.com.au> wrote:
>
> 
> 
> Andrew Morton wrote:
> 
> >Greg KH <greg@kroah.com> 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:
> 
> atomic_inc();
> if (atomic_dec_and_test())
>     release();
> 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
errors".


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


(Log in to post comments)


Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds