Re: [PATCH] workaround minor lockdep bug triggered bymm_take_all_locks

From: Andrew Morton
Date: Mon Aug 04 2008 - 17:42:40 EST


On Mon, 4 Aug 2008 23:30:18 +0200
Andrea Arcangeli <andrea@xxxxxxxxxxxx> wrote:

> Now perhaps I misunderstood lockdep entirely

You did ;)

At runtime lockdep will "learn" the lock ordering rules, building a
graph in memory. If it ever sees the thus-learnt rules violated, it
will warn.


Simple example:


static DEFINE_MUTEX(a);
static DEFINE_MUTEX(b);

void f1(void)
{
mutex_lock(a);
mutex_lock(b);
}

void f2(void)
{
mutex_lock(b);
mutex_lock(a);
}

void doit(void)
{
f1();
f2();
}



lockdep will warn here about the ranking violation. As soon as it
occurs. Even though the system never deadlocked.

It's very very clever and powerful.
--
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/