mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@suse.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Alan Stern" <stern@rowland.harvard.edu>,
	"Kay Sievers" <kay.sievers@suse.de>,
	gregkh@suse.de, kasievers@suse.de,
	"USB list" <linux-usb@vger.kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Ingo Molnar" <mingo@elte.hu>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: driver/base/dd.c lockdep warning
Date: Wed, 2 Sep 2009 20:53:16 +0200	[thread overview]
Message-ID: <20090902185315.GU28804@bolzano.suse.de> (raw)
In-Reply-To: <1251887933.7547.141.camel@twins>

On Wed, Sep 02, Peter Zijlstra wrote:

> 
> So the proposal I currently have to solve this is to allocate 48 lock
> classes:
> 
> struct lock_class_key device_tree_depth[MAX_LOCK_DEPTH];
> 
> and when creating a new device node, set the lock class corresponding
> the depth in the tree:
> 
>   mutex_lock_init(&device->lock);
>   BUG_ON(device->depth >= MAX_LOCK_DEPTH); // surely we're not that deep
>   lockdep_set_class(&device->lock, device_tree_depth + device->depth);
>   ...
>   mutex_lock(&device->lock); /* already have parent locked */
>   device_attach(device, parent);
> 
> and take multiple child locks using:
> 
>   mutex_lock_nest_lock(&device->lock, &device->parent->lock);
> 
> Which, I think should work for most cases out there.
> 
> Alan had some funny corner cases, but I think he wasn't sure whether
> those would indeed show up in reality.

JFYI, I tried to get away with just parent, child and normal class but
the problem is that device_add() is called recursive via driver probing
code. So either we change that (and iterate down the device tree) or we need
to implement what you proposed.

Cheers,
Jan

      parent reply	other threads:[~2009-09-02 18:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.44L0.0909011146030.3190-100000@iolanthe.rowland.org>
2009-09-02 10:38 ` Peter Zijlstra
2009-09-02 14:22   ` Alan Stern
2009-09-02 18:53   ` Jan Blunck [this message]

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=20090902185315.GU28804@bolzano.suse.de \
    --to=jblunck@suse.de \
    --cc=gregkh@suse.de \
    --cc=kasievers@suse.de \
    --cc=kay.sievers@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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