Re: WARNING: at kernel/lockdep.c:690 __lock_acquire+0x168/0x164b()

From: Sergey Senozhatsky
Date: Mon Nov 07 2011 - 03:46:12 EST


On (11/07/11 12:54), Yong Zhang wrote:
> > > > Understood. If someone can come up with a simple patch which could
> > > > cover the case I mentioned before, that would be great.
> > > > /me goes to poke at it.
> > >
> > > I dunno whether this is related but I get the following on 3.1:
> > >
> >
> > I think this is different problem. Failed check that lockdep key is marked as `static'.
>
> Actually the lockdep_init_map() in __lock_set_class could lead to
> more problem, such as: certain rq->lock could have different 'key'
> with what we give them in sched_init() because rq is defined staticly.
>
> Given that, we could have another typical race:
>
> CPU A CPU B
> lock_set_subclass(lockA);
> lock_set_class(lockA);
> /* lockA->class_cache[] is not set */
> register_lock_class(lockA);
> look_up_lock_class(lockA); /* retrun NULL */
> lockdep_init_map(lockA);
> /* lockA->name is cleared */
> memset(lockA);
> if (!static_obj(lock->key))
> /* we get warning here */
> lock->name = name;
>
>
> So memset() in lockdep_init_map() is still the culprit IMHO.
>

Hm, agreed, that still could be the reason.
I guess a little more information may be helpful in some cases.

---
Print key address when attempt to register non-static lock key detected.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>

---

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e69434b..de8a996 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -729,7 +729,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
*/
if (!static_obj(lock->key)) {
debug_locks_off();
- printk("INFO: trying to register non-static key.\n");
+ printk("INFO: trying to register non-static key at address %p.\n", lock->key);
printk("the code is fine but needs lockdep annotation.\n");
printk("turning off the locking correctness validator.\n");
dump_stack();

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