From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Pete Zaitcev <zaitcev@redhat.com>,
greg@kroah.com, linux-kernel@vger.kernel.org,
jglauber@redhat.com, xenia@us.ibm.com, wein@de.ibm.com
Subject: Re: dev->release = (void (*)(struct device *))kfree;
Date: Tue, 25 Oct 2005 08:44:16 +0200 [thread overview]
Message-ID: <20051025064416.GA14902@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <1130214982.7919.96.camel@gaston>
On Tue, Oct 25, 2005 at 02:36:21PM +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2005-10-24 at 20:10 -0700, Pete Zaitcev wrote:
> > I seem to recall the discussion about this, but very dimly. Would someone
> > be so kind to remind me, why the attached patch cannot be used?
>
> If your struct device becomes a member of your vmlogrdr_priv structure,
> then you need to tie the lifetime of that structure to the one of the
> struct device kobject. Thus, you need to provide a "release" callback
> that frees your entire vmlogrdr_priv structure and of course not free it
> yourself (but simply consider it lost after you have called
> device_unregister).
>
> In addition, if you are in the module, you get into funky issues since
> you must make sure your free routine doesn't "go away" with your module
> before the object is freed (it may be held a long time in memory by some
> userland thing opening a sysfs file to it). If you set the owner field
> of the kobj, your module should be held there (but may become totally
> un-rmmod'able in some circumstances, how fun...)
>
> If you need to keep your vmlogrdr_priv structure around a little while
> longer after device_unregister(), just increase it's refcount before
> doing device_unregister() and drop it when you don't need it anymore. It
> will still be unregistered (removed from the various lists) but the
> release() callback won't be called until the last user.
For the same reason I tried several times to _introduce_ the
"dev->release = (void (*)(struct device *))kfree" stuff in the zfcp device
driver, but Greg objected every time that it wouldn't be necessary.
I still disagree with him and that's why the zfcp module doesn't have a
module_exit function :)
Heiko
prev parent reply other threads:[~2005-10-25 6:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-25 3:10 Pete Zaitcev
2005-10-25 4:36 ` Benjamin Herrenschmidt
2005-10-25 6:44 ` Heiko Carstens [this message]
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=20051025064416.GA14902@osiris.boeblingen.de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=greg@kroah.com \
--cc=jglauber@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wein@de.ibm.com \
--cc=xenia@us.ibm.com \
--cc=zaitcev@redhat.com \
/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®