Re: driver/base/dd.c lockdep warning

From: Jan Blunck
Date: Wed Sep 02 2009 - 14:53:24 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/