From: viro@parcelfarce.linux.theplanet.co.uk
To: Greg KH <greg@kroah.com>
Cc: Linus Torvalds <torvalds@osdl.org>,
Alan Stern <stern@rowland.harvard.edu>,
Kernel development list <linux-kernel@vger.kernel.org>,
Patrick Mochel <mochel@digitalimplant.org>
Subject: Re: PATCH: (as177) Add class_device_unregister_wait() and platform_device_unregister_wait() to the driver model core
Date: Fri, 23 Jan 2004 19:45:46 +0000 [thread overview]
Message-ID: <20040123194546.GK21151@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20040123181106.GD23169@kroah.com>
On Fri, Jan 23, 2004 at 10:11:06AM -0800, Greg KH wrote:
> On Fri, Jan 23, 2004 at 09:42:09AM -0800, Linus Torvalds wrote:
> >
> >
> > On Fri, 23 Jan 2004, Alan Stern wrote:
> > >
> > > Since I haven't seen any progress towards implementing the
> > > class_device_unregister_wait() and platform_device_unregister_wait()
> > > functions, here is my attempt.
> >
> > So why would this not deadlock?
>
> It will deadlock if the user does something braindead like:
> rmmod foo < /sys/class/foo_class/foo1/file
>
> Now I know the network code can handle something like that, but they
> have their own thread to handle issues like this... It's not sane to
> make every driver subsystem do that...
Network code does *NOT* wait for references to kobject to disappear.
->release() for those buggers is not in a module and freeing can
happen way after the rmmod. No threads involved.
What it does wait for is different - in effect, net_device has a special-cased
rwsem in it, heavily optimised for down_read(). dev_hold() is an equivalent
of down_read(). dev_put() - up_read(). And unregister_netdev() does an
equivalent of down_write() after removing from all search structures.
That's what it is waiting for - it wants all readers (semaphore is unfair)
to go away. It's not a refcounting issue at all - it's an exclusion around
the net_device shutdown, freeing resources, etc.
There was an optimistic attempt to turn that animal into sysfs refcount.
It didn't work - we had to add real refcounting there and make sysfs code
do essentially an equivalent of down_try_read() before accessing the guts
of net_device(). And we have ->release() for those buggers in core kernel.
next prev parent reply other threads:[~2004-01-23 19:45 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-23 16:58 Alan Stern
2004-01-23 17:42 ` Linus Torvalds
2004-01-23 18:03 ` Alan Stern
2004-01-23 18:10 ` viro
2004-01-23 18:18 ` Greg KH
2004-01-23 18:15 ` Linus Torvalds
2004-01-23 18:31 ` Greg KH
2004-01-23 18:11 ` Greg KH
2004-01-23 18:19 ` Linus Torvalds
2004-01-23 18:27 ` Greg KH
2004-01-25 17:32 ` Alan Stern
2004-01-25 19:02 ` Linus Torvalds
2004-01-25 20:21 ` viro
2004-01-27 6:51 ` Rusty Russell
2004-01-27 13:56 ` Roman Zippel
2004-01-27 23:29 ` Rusty Russell
2004-01-28 2:36 ` Roman Zippel
2004-01-28 3:54 ` Rusty Russell
2004-01-25 23:12 ` Steve Youngs
2004-01-26 3:22 ` Adam Kropelin
2004-01-26 5:06 ` Steve Youngs
2004-01-26 5:21 ` Valdis.Kletnieks
2004-01-26 5:55 ` Steve Youngs
2004-01-26 6:25 ` Valdis.Kletnieks
2004-01-26 8:48 ` Helge Hafting
2004-01-26 15:50 ` Adam Kropelin
2004-01-26 16:22 ` Roman Zippel
2004-01-27 19:32 ` Russell King
2004-01-27 20:28 ` Greg KH
2004-01-27 20:29 ` Greg KH
2004-01-28 2:03 ` Roman Zippel
2004-01-28 2:17 ` viro
2004-01-28 2:53 ` Roman Zippel
2004-01-27 6:41 ` Rusty Russell
2004-01-23 19:45 ` viro [this message]
2004-01-26 5:50 ` Rusty Russell
2004-01-26 15:51 ` Alan Stern
2004-01-27 22:55 ` Rusty Russell
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=20040123194546.GK21151@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.org \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@osdl.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
Powered by JetHome