login
Header Space

 
 

Re: device struct bloat

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Greg KH <greg@...>
Cc: Peter Zijlstra <peterz@...>, Oliver Neukum <oneukum@...>, Stephen Hemminger <shemminger@...>, <linux-kernel@...>, apw <apw@...>, Ingo Molnar <mingo@...>, <linux-usb-devel@...>
Date: Tuesday, November 6, 2007 - 11:36 am

On Mon, 5 Nov 2007, Greg KH wrote:


In fact things don't work this way.  The list above stops short after
"add usb host controller devices"; the probe routines for host
controllers do not scan for USB hubs or other USB devices.  Instead
they are detected by a completely separate thread (khubd).


I gather the idea is to convert dev->sem to a mutex.  This idea had 
occurred to me a long time ago but I didn't pursue it because of the 
sheer number of places where dev->sem gets used, not to mention the 
lockdep problems.

You can't possibly solve the lockdep problems here with a simple-minded
approach like your DRIVER_NORMAL, DRIVER_PARENT, etc.  The device tree
is arbitrarily deep & wide, and there is at least one routine that
acquires the semaphores for _all_ the devices in the tree.  This fact
alone seems to preclude using lockdep for device locks.  (If there was 
a form of mutex_lock() that bypassed the lockdep checks, you could use 
it and avoid these issues.)

Deadlock is a serious consideration.  For the most part, routines 
locking devices do so along a single path in the tree.  For this simple 
case the rule is: Never acquire a parent's lock while holding the 
child's lock.

The routine that locks all the devices acquires the locks in order of 
device registration.  The idea here is that children are always 
registered _after_ their parents, so this should be compatible with the 
previous rule.  But there is a potential problem: device_move() can 
move an older child under a younger parent!

Right now we have no way to deal with this.  There has been some 
discussion of reordering the dpm_active list when a device is moved, 
but so far nothing has been done about it.

Alan Stern

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
device struct bloat, Stephen Hemminger, (Sat Nov 3, 3:48 pm)
Re: device struct bloat, Peter Zijlstra, (Sun Nov 4, 4:29 pm)
Re: device struct bloat, Greg KH, (Sun Nov 4, 11:58 pm)
Re: device struct bloat, Peter Zijlstra, (Mon Nov 5, 6:46 am)
Re: device struct bloat, Peter Zijlstra, (Mon Nov 5, 6:57 am)
Re: device struct bloat, Greg KH, (Mon Nov 5, 6:49 pm)
Re: device struct bloat, Alan Stern, (Tue Nov 6, 11:36 am)
Re: device struct bloat, Peter Zijlstra, (Tue Nov 6, 11:58 am)
Re: device struct bloat, Alan Stern, (Tue Nov 6, 12:32 pm)
Re: device struct bloat, Peter Zijlstra, (Tue Nov 6, 1:19 pm)
Re: device struct bloat, Alan Stern, (Tue Nov 6, 2:05 pm)
Re: device struct bloat, Peter Zijlstra, (Tue Nov 6, 2:57 pm)
Re: device struct bloat, Alan Stern, (Wed Nov 7, 12:42 pm)
Re: device struct bloat, Peter Zijlstra, (Tue Nov 6, 5:48 am)
Re: [linux-usb-devel] device struct bloat, David Brownell, (Mon Nov 5, 9:38 pm)
Re: [linux-usb-devel] device struct bloat, Peter Zijlstra, (Tue Nov 6, 5:43 am)
Re: device struct bloat, Stefan Richter, (Mon Nov 5, 6:33 pm)
Re: device struct bloat, Greg KH, (Sat Nov 3, 7:14 pm)
speck-geostationary