Re: [linux-usb-devel] How should an exit routine wait for release() callbacks?

2007-04-17 Thread Alan Stern
On Mon, 16 Apr 2007, Greg KH wrote:

> > > I've got a module which registers a struct device.  (It represents a
> > > virtual device, not a real one, but that doesn't matter.)
> 
> Wait, that's the issue right there.
> 
> Don't do that.
> 
> devices should be created by busses or the platform core, which owns the
> release function for them.  Individual drivers should not create
> devices.
> 
> Hm, but then, how would you ever unload a bus, as the same issue might
> be there too...
> 
> Any specific code in the kernel you can point to that has this issue
> today?

I first noticed it while working with dummy_hcd.  It creates a virtual 
host controller platform device and a virtual device controller platform 
device.  Its exit routine doesn't wait (and has no way to wait) for the 
release methods of those devices to finish executing.

But the same issue tends to pop up anywhere you have a "bridge" device --
one that connects two different kinds of bus.  For instance, a PC-card
essentially bridges a CardBus to whatever you can plug into that card.  
usb-storage essentially bridges a USB bus to a SCSI bus.  uhci-hcd
essentially bridges a PCI bus to a USB bus.

The problem itself isn't very noticeable.  Existing uses of
try_module_get() generally reduce it to an unlikely race, and the
uncoupling of sysfs from devices will make it even rarer.

But the problem still exists potentially.

Alan Stern

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


Re: [linux-usb-devel] How should an exit routine wait for release() callbacks?

2007-04-17 Thread Cornelia Huck
On Mon, 16 Apr 2007 15:12:47 -0700,
Greg KH <[EMAIL PROTECTED]> wrote:

> Ah, just found this original thread, now Cornelia's patches make more
> sense...

I would have included a pointer, but couldn't access marc yesterday
evening, sorry...

> 
> On Fri, Apr 13, 2007 at 11:24:58AM -0400, Alan Stern wrote:
> > Tejun, it just occurred to me that you would be interested in this email 
> > thread.  Just to bring you up to speed, here's the original question:
> > 
> > > I've got a module which registers a struct device.  (It represents a
> > > virtual device, not a real one, but that doesn't matter.)
> 
> Wait, that's the issue right there.
> 
> Don't do that.
> 
> devices should be created by busses or the platform core, which owns the
> release function for them.  Individual drivers should not create
> devices.

There are drivers that do it, for a variety of reasons.

> 
> Hm, but then, how would you ever unload a bus, as the same issue might
> be there too...

Exactly :) This would imply busses/subsystems could never be unloadable
modules.

> 
> Any specific code in the kernel you can point to that has this issue
> today?

zfcp comes to mind. They register some units in zfcp_aux.c, which don't
have anything to do with the bus the zfcp adapter is on (the ccw bus).
Currently, that is "solved" by disallowing zfcp module unloading.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [linux-usb-devel] How should an exit routine wait for release() callbacks?

2007-04-16 Thread Greg KH
Ah, just found this original thread, now Cornelia's patches make more
sense...

On Fri, Apr 13, 2007 at 11:24:58AM -0400, Alan Stern wrote:
> Tejun, it just occurred to me that you would be interested in this email 
> thread.  Just to bring you up to speed, here's the original question:
> 
> > I've got a module which registers a struct device.  (It represents a
> > virtual device, not a real one, but that doesn't matter.)

Wait, that's the issue right there.

Don't do that.

devices should be created by busses or the platform core, which owns the
release function for them.  Individual drivers should not create
devices.

Hm, but then, how would you ever unload a bus, as the same issue might
be there too...

Any specific code in the kernel you can point to that has this issue
today?

thanks,

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


Re: [linux-usb-devel] How should an exit routine wait for release() callbacks?

2007-04-16 Thread Robert Marquardt

Alan Stern wrote:


On the other hand, this proposal involves adding a fair amount of overhead
(all those .owner fields) for a rather small benefit.  And it involves
modifying a core kernel subsystem (kernel/module.c).  All to prevent
certain unlikely sorts of errors when removing a module -- something which
Linus has said repeatedly need not be supported terribly well.

So I'm uncertain whether other people will be in favor of all this.


I think Linus is in error here. Either do it right or not at all. I 
would say that modules should work *always* and without any conceptual 
problem.

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