Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm re-arrange the end of uvm_page_recolor() to avoid th...



details:   https://anonhg.NetBSD.org/src/rev/17e4daca88eb
branches:  trunk
changeset: 770012:17e4daca88eb
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Sep 30 05:29:12 2011 +0000

description:
re-arrange the end of uvm_page_recolor() to avoid the multiple exit
points.  move the call to uvm_pager_realloc_emerg() to after we
drop the uvm_fpageqlock, since it may be taken again in uvm_km_alloc().

fixes LOCKDEBUG crashes with the previous change.

diffstat:

 sys/uvm/uvm_page.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (46 lines):

diff -r f1973e5db718 -r 17e4daca88eb sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Fri Sep 30 05:07:39 2011 +0000
+++ b/sys/uvm/uvm_page.c        Fri Sep 30 05:29:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.176 2011/09/28 22:52:15 matt Exp $      */
+/*     $NetBSD: uvm_page.c,v 1.177 2011/09/30 05:29:12 mrg Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.176 2011/09/28 22:52:15 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.177 2011/09/30 05:29:12 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -1045,16 +1045,20 @@
                ucpu->page_free[lcv].pgfl_buckets = pgfl.pgfl_buckets;
        }
 
-       uvm_pager_realloc_emerg();
-
-       if (have_recolored_pages) {
-               mutex_spin_exit(&uvm_fpageqlock);
-               free(oldbucketarray, M_VMPAGE);
-               return;
-       }
+       if (!have_recolored_pages)
+               oldbucketarray = NULL;
 
        have_recolored_pages = true;
        mutex_spin_exit(&uvm_fpageqlock);
+
+       if (oldbucketarray)
+               free(oldbucketarray, M_VMPAGE);
+
+       /*
+        * this calls uvm_km_alloc() which may want to hold
+        * uvm_fpageqlock.
+        */
+       uvm_pager_realloc_emerg();
 }
 
 /*



Home | Main Index | Thread Index | Old Index