On Sat, Sep 28, 2013 at 09:52:07PM +0200, Ingo Molnar wrote:
> Index: tip/mm/mmap.c
> ===================================================================
> --- tip.orig/mm/mmap.c
> +++ tip/mm/mmap.c
> @@ -2955,15 +2955,15 @@ static void vm_lock_anon_vma(struct mm_s
>                * The LSB of head.next can't change from under us
>                * because we hold the mm_all_locks_mutex.
>                */
> -             down_write_nest_lock(&anon_vma->root->rwsem, &mm->mmap_sem);
> +             write_lock(&anon_vma->root->rwlock);

Tssk, you should know better...

But yes; this is the most horrid site; however I think it was mostly
file based VMAs that caused the immense amount of locks taken since this
is only done 'very' early on in the life of KVM.

I can't remember how early; I hope almost instantly and certainly before
spawning all the various vcpu threads as that would create all the
thread stacks which are anon and would indeed blow up the non-preempt
time here.

So if we keep i_mmap_mutex -- and I hope we do; that unmap_mutex horror
wasn't pretty at all -- see commit 97a894136 . The below shouldn't be
too bad I think/hope.


---
--- a/include/linux/rwlock.h
+++ b/include/linux/rwlock.h
@@ -64,6 +64,19 @@ do {                                                         
\
 #define write_lock(lock)       _raw_write_lock(lock)
 #define read_lock(lock)                _raw_read_lock(lock)
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+# define write_lock_nest_lock(lock, nest_lock)                         \
+do {                                                                   \
+       typecheck(struct lockdep_map *, &(nest_lock)->dep_map);         \
+       preempt_disable();                                              \
+       lock_acquire_exclusive(&lock->dep_map, 0, 0,                    \
+                              &(nest_lock)->dep_map, _RET_IP_);        \
+       LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);  \
+} while (0)
+#else
+# define write_lock_nest_lock(lock, nest_lock) write_lock(lock)
+#endif
+
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
 
 #define read_lock_irqsave(lock, flags)                 \
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2955,7 +2955,7 @@ static void vm_lock_anon_vma(struct mm_s
                 * The LSB of head.next can't change from under us
                 * because we hold the mm_all_locks_mutex.
                 */
-               write_lock(&anon_vma->root->rwlock);
+               write_lock_nest_lock(&anon_vma->root->rwlock);
                /*
                 * We can safely modify head.next after taking the
                 * anon_vma->root->rwlock. If some other vma in this mm shares
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to