From: "Peter Kjellerstedt" <peter.kjellerstedt@axis.com>
To: "Greg KH" <greg@kroah.com>, <linux-kernel@vger.kernel.org>
Subject: RE: [RFC] kref, a tiny, sane, reference count object
Date: Sat, 13 Mar 2004 10:10:36 +0100 [thread overview]
Message-ID: <50BF37ECE4954A4BA18C08D0C2CF88CB36613F@exmail1.se.axis.com> (raw)
> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org
> [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Greg KH
> Sent: Saturday, March 13, 2004 09:20
> To: linux-kernel@vger.kernel.org
> Subject: [RFC] kref, a tiny, sane, reference count object
>
> In thinking about people's complaints about the current
> kobject interface, a lot of people don't like the
> "complexity" of what is necessary to use a kobject.
> If all you want is something to handle reference
> counting properly, a kobject can seem a bit "large".
>
> For all of those people, this patch is for you.
> Introducing struct kref. A tiny (only 8 bytes on a
> 32bit platform) that will properly handle reference
> counting any structure you want to use it for. Note
> that you will have to be careful around the cleanup
> period (but that can be easily handled by the user
> with regards to not trying to grab a "new" reference
> if you don't already have one, once the object is
> gone, just like kobjects and sysfs today work.)
>
> I've implemented kobjects using a kref to handle the
> reference counting portion, but will leave that patch
> and change for 2.7, as it will add 4 more bytes (on a
> 32bit platform) to every kobject, and that wouldn't
> be nice this early in the 2.6 series. For now, krefs
> can stand on their own.
>
> I've already found loads of places in the kernel that
> can use this structure to clean up their logic, and
> will probably be converting a number of them over time
> to use them. But no, Al, I will not say this can be
> used to replace the atomic_t count you have in inodes,
> as that count is horribly abused in ways I never really
> wanted to know about (negative counts mean something
> "special"? eeeeeek....)
>
> Anyway, here's a patch against 2.6.4 that adds krefs
> to the kernel. I'll follow up with a patch that
> converts the usb-serial core from using kobjects to
> using krefs instead.
>
> Comments are appreciated and welcomed.
>
> thanks,
>
> greg k-h
Looks simple enough. But I have a small question.
In kref_get() and kref_cleanup(), kref is verified
not to be NULL before being used. However, this is
not done in kref_put(). An oversight, or as intended?
//Peter
next reply other threads:[~2004-03-13 9:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-13 9:10 Peter Kjellerstedt [this message]
2004-03-13 18:15 ` Greg KH
[not found] <1zhdz-5uL-3@gated-at.bofh.it>
[not found] ` <1zhdz-5uL-1@gated-at.bofh.it>
[not found] ` <1zm3F-2ex-7@gated-at.bofh.it>
2004-03-13 20:43 ` Andi Kleen
[not found] <1zcH2-KO-11@gated-at.bofh.it>
2004-03-13 13:06 ` Andi Kleen
2004-03-13 18:14 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2004-03-13 8:20 Greg KH
2004-03-14 0:34 ` Andrew Morton
2004-03-14 2:55 ` Greg KH
2004-03-14 3:30 ` Nick Piggin
2004-03-14 4:10 ` Andrew Morton
2004-03-14 4:20 ` Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50BF37ECE4954A4BA18C08D0C2CF88CB36613F@exmail1.se.axis.com \
--to=peter.kjellerstedt@axis.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®