diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-02-08 10:38:52 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-02-17 12:01:15 +0100 |
commit | 68fd52c6f54e34a361903c544ca342f1cda4e291 (patch) | |
tree | 8752f2c2b59634a24e82ab0a16604a41bdc8e31d | |
parent | e99b72b886bf8efc2c73c410e5de3a383c436a17 (diff) | |
download | lwn-68fd52c6f54e34a361903c544ca342f1cda4e291.tar.gz lwn-68fd52c6f54e34a361903c544ca342f1cda4e291.zip |
lockdep: Add novalidate class for dev->mutex
On Fri, 5 Feb 2010, Peter Zijlstra wrote:
> Something like the below might work, but it should go along with a
> checkpatch.pl mod to ensure we don't grow any new users (just don't feel
> like brushing up my perl fu enough to actually make sense of that
> script)
I tried this out and it does work; no more lockdep warnings during
bootup. The complete patch is below.
But before we apply this, it might be worthwhile to spend a little time
figuring out how many independent device trees there really are and
whether they can be handled with separate depth-associated lockdep
classes. It's not at all obvious that they can.
Alan Stern
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | drivers/base/core.c | 1 | ||||
-rw-r--r-- | include/linux/lockdep.h | 2 | ||||
-rw-r--r-- | kernel/lockdep.c | 5 |
3 files changed, 8 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 5b91be31cd2d..01193497d7a8 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -550,6 +550,7 @@ void device_initialize(struct device *dev) kobject_init(&dev->kobj, &device_ktype); INIT_LIST_HEAD(&dev->dma_pools); mutex_init(&dev->mutex); + lockdep_set_class(&dev->mutex, &__lockdep_no_validate__); spin_lock_init(&dev->devres_lock); INIT_LIST_HEAD(&dev->devres_head); device_init_wakeup(dev, 0); diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b25d1b53df0d..0eb1ece94d47 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -40,6 +40,8 @@ struct lock_class_key { struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; }; +extern struct lock_class_key __lockdep_no_validate__; + #define LOCKSTAT_POINTS 4 /* diff --git a/kernel/lockdep.c b/kernel/lockdep.c index a53d4fbb721e..76b8fbba675c 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -2529,6 +2529,8 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name, } EXPORT_SYMBOL_GPL(lockdep_init_map); +struct lock_class_key __lockdep_no_validate__; + /* * This gets called for every mutex_lock*()/spin_lock*() operation. * We maintain the dependency maps and validate the locking attempt: @@ -2561,6 +2563,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, return 0; } + if (lock->key == &__lockdep_no_validate__) + check = 1; + if (!subclass) class = lock->class_cache; /* |