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

From: David Rientjes
Date: Thu Oct 20 2011 - 17:31:46 EST


On Thu, 20 Oct 2011, Tejun Heo wrote:

> > Tejun, would you like to revert f59de8992aa6 ("lockdep: Clear whole
> > lockdep_map on initialization") since it fixes this lockdep warning?
>
> Hmmm... the issue was that kmemcheck noticed that memory regions in
> lockdep_map are accessed before being set to any value. I'm feeling
> dim as usual and don't understand what's going on here. The function
> looks like the following.
>
>
> void lockdep_init_map(struct lockdep_map *lock, const char *name,
> struct lock_class_key *key, int subclass)
> {
> memset(lock, 0, sizeof(*lock));
>
> #ifdef CONFIG_LOCK_STAT
> lock->cpu = raw_smp_processor_id();
> #endif
> if (DEBUG_LOCKS_WARN_ON(!name)) {
> lock->name = "NULL";
> return;
> }
>
> lock->name = name;
>
>
> So, according to this thread, the problem is that the memset() clears
> lock->name field, right?

Right, and reverting f59de8992aa6 ("lockdep: Clear whole lockdep_map on
initialization") seems to fix the lockdep warning.

> But how can that be a problem? lock->name
> is always set to either "NULL" or @name. Why would clearing it before
> setting make any difference? What am I missing?
>

The scheduler (in sched_fair and sched_rt) calls lock_set_subclass() which
sets the name in double_unlock_balance() to set the name but there's a
race between when that is cleared with the memset() and setting of
lock->name where lockdep can find them to match.
--
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/