Re: [PATCH] workaround minor lockdep bug triggered by mm_take_all_locks

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>
Cc: <penberg@...>, <a.p.zijlstra@...>, <davej@...>, <rdreier@...>, <torvalds@...>, <davem@...>, <jeremy@...>, <hugh@...>, <mingo@...>, <linux-kernel@...>, <arjan@...>
Date: Monday, August 4, 2008 - 6:12 pm

On Mon, Aug 04, 2008 at 02:41:14PM -0700, Andrew Morton wrote:

Yes I wasn't aware of the AB BA feature that doesn't require the
inversion to happen on both cpus at the same time, despite having
spent weeks when it was kernel crashing systems at boot (which shows
it's not immediately easy to understand how that thing works by
reading the code).

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

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

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

void f3(void)
{
	mutex_lock(a);
	mutex_lock(b);
	mutex_unlock(a);
	mutex_unlock(b);
}

void f4(void)
{
	mutex_lock(b);
	mutex_lock(a);
	mutex_unlock(b);
	mutex_unlock(a);
}

void doit(void)
{
	f1();
	f2();
	stop_machine(f3);
	stop_machine(f4);
}


I'm curious, does it also handle the above? I mean not a big deal to
refactor the code to shutdown lockdep warnings, but it doesn't look
that clever to me. It seems just clever the minimum enough to be
useful with its AB BA memory.

Now I see lockdep has a good point to exist, for the lock inversion
"memory" but this is by no mean a feature I can remotely like in
general given how inaccurate and prone for false positives it is. It
looks more a necessary evil to deal with, like I tried to do with my
patch (even before understanding it was more useful than what I
thought initially).
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 9:03 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Thu Aug 7, 7:25 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 2:06 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 2:54 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 3:26 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Mon Aug 4, 3:31 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 11:27 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Nick Piggin, (Wed Oct 8, 11:52 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 1:18 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Wed Oct 8, 11:43 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 12:03 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Wed Oct 8, 12:19 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 12:53 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 4:16 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 3:39 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Roland Dreier, (Mon Aug 4, 10:07 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 10:19 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Roland Dreier, (Mon Aug 4, 10:26 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 10:32 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Dave Jones, (Mon Aug 4, 10:53 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 10:56 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 12:26 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 12:38 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), David Miller, (Mon Aug 4, 5:32 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 1:27 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 2:48 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 1:46 pm)
Re: [PATCH] workaround minor lockdep bug triggered by mm_tak..., Andrea Arcangeli, (Mon Aug 4, 6:12 pm)