Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrea Arcangeli
Date: Monday, August 4, 2008 - 10:46 am

From: Andrea Arcangeli <andrea@qumranet.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@qumranet.com>
---

On Mon, Aug 04, 2008 at 07:27:28PM +0200, Andrea Arcangeli wrote:

(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)


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();
 	}
 }
 
--
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, 6:03 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Roland Dreier, (Mon Aug 4, 7:07 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 7:19 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Roland Dreier, (Mon Aug 4, 7:26 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 7:32 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Dave Jones, (Mon Aug 4, 7:53 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 7:56 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 9:26 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 9:38 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 10:27 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Andrea Arcangeli, (Mon Aug 4, 10:46 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 11:06 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 11:48 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 11:54 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 12:26 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Mon Aug 4, 12:31 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Mon Aug 4, 12:39 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Jeremy Fitzhardinge, (Mon Aug 4, 1:16 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), David Miller, (Mon Aug 4, 2:32 pm)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Peter Zijlstra, (Thu Aug 7, 4:25 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 8:27 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Wed Oct 8, 8:43 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Nick Piggin, (Wed Oct 8, 8:52 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 9:03 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Linus Torvalds, (Wed Oct 8, 9:19 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 9:53 am)
Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock(), Steven Rostedt, (Wed Oct 8, 10:18 am)