From: Tejun Heo <htejun@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>,
hugh@veritas.com, cornelia.huck@de.ibm.com,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Oliver Neukum <oliver@neukum.name>,
maneesh@in.ibm.com, rpurdie@rpsys.net,
James Bottomley <James.Bottomley@SteelEye.com>,
Jeff Garzik <jgarzik@pobox.com>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [RFD driver-core] Lifetime problems of the current driver model
Date: Sun, 08 Apr 2007 11:55:45 +0900 [thread overview]
Message-ID: <461859B1.2030506@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0704071145370.31604-100000@netrider.rowland.org>
Hello,
Alan Stern wrote:
>> The problem here is that kobjec_get() in sysfs_schedule_callback()
>> doesn't grab the module backing the kobject it's grabbing. By the
>> time (ss->func)(ss->kobj) runs, scsi_mod is already gone.
>
> As the author of this routine, I wish you had included my name in your
> CC: list. :-(
Sorry. I'll from the next time. I posted related patchset yesterday.
You can see it at...
http://thread.gmane.org/gmane.linux.kernel/513334
> The problem here isn't exactly as you described. scsi_mod needs to be
> pinned (1) because it is the owner of the kobject and hence will be
> called when the kobject is released, and (2) because it is the owner
> of the callback routine. However this is just a detail; clearly the
> bug needs to be fixed.
>
> One possibility would be to have scsi_mod's exit_scsi() routine call
> flush_scheduled_work(). Another would be to add such a call in
> sys_delete_module(). Neither of these is attractive. They would add
> overhead when it's not needed, and they would deadlock if a workqueue
> routine tried to unload a module.
>
> On balance, the patch below seems better. Do you agree?
Agreed. Grabbing module on function schedule should fix the problem.
> With regard to your analysis of lifetime issues, there is a whole
> aspect you did not mention. A basic assumption of the refcounting
> approach is that once X has a reference to Y, X can freely access and
> use Y as much as it wants until it drops the reference.
>
> However this is not true when X is a device driver and Y is a device
> structure. Drivers can be unbound from devices. If X has been
> unbound from Y then it must not access Y again, no matter how many
> references it possesses. After all, some other driver may have bound
> to Y in the meantime; this other driver would not appreciate the
> interference.
>
> Just as bad, if Y represents a hot-pluggable device then some other
> device may have been plugged in and may be using Y's old address. We
> don't want X sending commands to a new device, thinking that it is Y!
>
> The complications caused by this requirement affect both the subsystem
> code and device drivers. Drivers must synchronize their release()
> methods with every action they take -- and refcounts cannot provide
> synchronization.
>
> A similar problem afflicts the char-device subsystem, and here even
> less care has been taken to address the issues. The race between
> open() and unregister() is resolved in many places by relying on the
> BKL!
>
> We should be able to make things better and easier than they are.
> Orphaning open sysfs files was a move in this direction. But I doubt
> they will ever become truly simple and clear.
Yeap, you're right. My goal is make driver detach point the automatic
final synchronization point such that after the driver unregisters
itself from all the upper layers including sysfs, it's guaranteed that
there's no user left to the driver or the device it was driving. Taking
sysfs out of the lifetime equation is a big step toward this goal.
Converting all subsystems and upper layers to immediately disconnect
from the device on driver detach would take some time but I don't think
it will be too difficult.
Thanks.
--
tejun
next prev parent reply other threads:[~2007-04-08 2:55 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-07 15:48 [RFD driver-core] Lifetime problems of the current driver model Alan Stern
2007-04-08 2:55 ` Tejun Heo [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-03-30 9:43 Tejun Heo
2007-03-30 12:29 ` James Bottomley
2007-03-30 13:15 ` Dmitry Torokhov
2007-03-30 17:58 ` James Bottomley
2007-03-30 18:18 ` Dmitry Torokhov
2007-03-30 13:38 ` Tejun Heo
2007-03-30 17:41 ` Greg KH
2007-03-30 18:19 ` James Bottomley
2007-04-01 19:59 ` Tejun Heo
2007-04-02 9:20 ` Cornelia Huck
2007-04-02 15:34 ` Cornelia Huck
2007-04-03 3:08 ` Tejun Heo
2007-04-02 9:33 ` Greg KH
2007-04-02 12:10 ` Maneesh Soni
2007-04-02 19:33 ` Luben Tuikov
2007-03-30 13:19 ` Cornelia Huck
2007-03-30 13:19 ` Tejun Heo
2007-03-30 13:40 ` Cornelia Huck
2007-03-30 13:58 ` Tejun Heo
2007-03-30 14:52 ` Cornelia Huck
2007-03-30 15:08 ` Tejun Heo
2007-03-30 19:31 ` Cornelia Huck
2007-03-31 3:12 ` Tejun Heo
2007-03-31 3:15 ` Tejun Heo
2007-03-31 16:08 ` Cornelia Huck
2007-03-31 16:14 ` Tejun Heo
2007-04-02 19:24 ` Luben Tuikov
2007-03-30 17:38 ` Greg KH
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=461859B1.2030506@gmail.com \
--to=htejun@gmail.com \
--cc=James.Bottomley@SteelEye.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--cc=greg@kroah.com \
--cc=hugh@veritas.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@in.ibm.com \
--cc=oliver@neukum.name \
--cc=rpurdie@rpsys.net \
--cc=stern@rowland.harvard.edu \
/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