All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>, Oliver Neukum <oneukum@suse.de>,
	Stephen Hemminger <shemminger@linux-foundation.org>,
	linux-kernel@vger.kernel.org, apw <apw@shadowen.org>,
	Ingo Molnar <mingo@elte.hu>,
	linux-usb-devel@lists.sourceforge.net
Subject: Re: device struct bloat
Date: Tue, 06 Nov 2007 16:58:04 +0100	[thread overview]
Message-ID: <1194364684.6289.40.camel@twins> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0711061021390.3883-100000@iolanthe.rowland.org>

On Tue, 2007-11-06 at 10:36 -0500, Alan Stern wrote:

> > > Would it be possible to break at the second scan, that is the device
> > > probe and stick that into a workqueue or something. Then we'd only ever
> > > have driver->device nesting.
> > 
> > Alan and Oliver have done some work in this area I think, combined with
> > the suspend/bind/unbind issues.  I'll let them comment on your patch :)
> 
> 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

That should never stop us from doing the right thing :-), also dev->sem
isn't used nearly as much as for example work_struct which was changed.

> , not to mention the lockdep problems.

Right, that is the only sort-of valid reason this has not been done yet.

> 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. 

*blink* someone needs to take all locks - why?

>  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.)

I'm sceptical of this, since its a simple tree (as opposed to a balanced
tree) a simple lock-coupling approach should be enough to guarantee
consistency.

> 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.

Sure, but once you have a parent's lock, you could unlock your
grandparent, no? (it having a locked child, your parent, should be
enough to guarantee its continued existence)

> 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!

Seems like a weird rule, a typical tree locking rule would be to lock
them top-down - such a rule can easily cope with moves: lock old parent,
lock child, lock new parent, move child, unlock all in reverse order.

> 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.

Like said, I think the tree locking model should be revisited. A
top-down locking model with lock-coupling should, from my ignorant
perspective, solve your problems.



  reply	other threads:[~2007-11-06 15:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-03 19:48 device struct bloat Stephen Hemminger
2007-11-03 23:14 ` Greg KH
2007-11-04 20:29 ` Peter Zijlstra
2007-11-05  3:58   ` Greg KH
2007-11-05 10:46     ` Peter Zijlstra
2007-11-05 10:57       ` Peter Zijlstra
2007-11-05 22:33         ` Stefan Richter
2007-11-05 22:49         ` Greg KH
2007-11-06  1:38           ` [linux-usb-devel] " David Brownell
2007-11-06  9:43             ` Peter Zijlstra
2007-11-06  9:48           ` Peter Zijlstra
2007-11-06 15:36           ` Alan Stern
2007-11-06 15:58             ` Peter Zijlstra [this message]
2007-11-06 16:32               ` Alan Stern
2007-11-06 17:19                 ` Peter Zijlstra
2007-11-06 18:05                   ` Alan Stern
2007-11-06 18:57                     ` Peter Zijlstra
2007-11-07 16:42                       ` Alan Stern

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=1194364684.6289.40.camel@twins \
    --to=peterz@infradead.org \
    --cc=apw@shadowen.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=mingo@elte.hu \
    --cc=oneukum@suse.de \
    --cc=shemminger@linux-foundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.