[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080804174659.GK11476@duo.random>
Date: Mon, 4 Aug 2008 19:46:59 +0200
From: Andrea Arcangeli <andrea@...ranet.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Dave Jones <davej@...hat.com>, Roland Dreier <rdreier@...co.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
David Miller <davem@...emloft.net>, jeremy@...p.org,
hugh@...itas.com, mingo@...e.hu, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock()
From: Andrea Arcangeli <andrea@...ranet.com>
Lockdep can't recognize if spinlocks are at a different address. So
trylock avoids lockdep to generate false positives. After lockdep will
be fixed this change can and should be reverted.
Signed-off-by: Andrea Arcangeli <andrea@...ranet.com>
---
On Mon, Aug 04, 2008 at 07:27:28PM +0200, Andrea Arcangeli wrote:
> I can reproduce this now yes after a 'make sync'.
(btw it's not like I forgot to sync, but I sync against the wrong
source tree previously because it was in the bash history, it's a bit
complicate to explain)
> I assume it can't understand the spinlock address is different (I
> think it uses the address as key only for static locks), so I wonder
> if you could call print_deadlock_bug() from the failure path of the
> spinlock to solve this?
In the meantime (as I doubt lockdep will get fixed any time soon) this
will workaround it.
diff -r 3469dce61df1 mm/mmap.c
--- a/mm/mmap.c Tue Jul 29 20:01:28 2008 +0200
+++ b/mm/mmap.c Mon Aug 04 19:41:53 2008 +0200
@@ -2279,8 +2279,13 @@ static void vm_lock_anon_vma(struct anon
/*
* The LSB of head.next can't change from under us
* because we hold the mm_all_locks_mutex.
+ *
+ * spin_lock would confuse lockdep who can't
+ * differentiate between the 'mapping' always changing
+ * address.
*/
- spin_lock(&anon_vma->lock);
+ while (!spin_trylock(&anon_vma->lock))
+ cpu_relax();
/*
* We can safely modify head.next after taking the
* anon_vma->lock. If some other vma in this mm shares
@@ -2310,7 +2315,13 @@ static void vm_lock_mapping(struct addre
*/
if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags))
BUG();
- spin_lock(&mapping->i_mmap_lock);
+ /*
+ * spin_lock would confuse lockdep who can't
+ * differentiate between the 'mapping' always changing
+ * address.
+ */
+ while (!spin_trylock(&mapping->i_mmap_lock))
+ cpu_relax();
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists