svn commit: r206910 - user/kmacy/head_page_lock_2/sys/vm

Kip Macy kmacy at FreeBSD.org
Tue Apr 20 20:09:46 UTC 2010


Author: kmacy
Date: Tue Apr 20 20:09:45 2010
New Revision: 206910
URL: http://svn.freebsd.org/changeset/base/206910

Log:
  replace conditional locking of page queue mutex with macros

Modified:
  user/kmacy/head_page_lock_2/sys/vm/vm_map.c
  user/kmacy/head_page_lock_2/sys/vm/vm_page.h

Modified: user/kmacy/head_page_lock_2/sys/vm/vm_map.c
==============================================================================
--- user/kmacy/head_page_lock_2/sys/vm/vm_map.c	Tue Apr 20 19:30:12 2010	(r206909)
+++ user/kmacy/head_page_lock_2/sys/vm/vm_map.c	Tue Apr 20 20:09:45 2010	(r206910)
@@ -1780,31 +1780,18 @@ vm_map_pmap_enter(vm_map_t map, vm_offse
 				p_start = p;
 			}
 		} else if (p_start != NULL) {
-#ifndef VM_PAGE_LOCK
-			if (!are_queues_locked) {
-				are_queues_locked = TRUE;
-				vm_page_lock_queues();
-			}
-#endif			
+			vm_page_lock_queues_cond(are_queues_locked);
 			pmap_enter_object(map->pmap, start, addr +
 			    ptoa(tmpidx), p_start, prot);
 			p_start = NULL;
 		}
 	}
 	if (p_start != NULL) {
-#ifndef VM_PAGE_LOCK
-		if (!are_queues_locked) {
-			are_queues_locked = TRUE;
-			vm_page_lock_queues();
-		}
-#endif		
+		vm_page_lock_queues_cond(are_queues_locked);
 		pmap_enter_object(map->pmap, start, addr + ptoa(psize),
 		    p_start, prot);
 	}
-#ifndef VM_PAGE_LOCK
-	if (are_queues_locked)
-		vm_page_unlock_queues();
-#endif	
+	vm_page_unlock_queues_cond(are_queues_locked);
 unlock_return:
 	VM_OBJECT_UNLOCK(object);
 }

Modified: user/kmacy/head_page_lock_2/sys/vm/vm_page.h
==============================================================================
--- user/kmacy/head_page_lock_2/sys/vm/vm_page.h	Tue Apr 20 19:30:12 2010	(r206909)
+++ user/kmacy/head_page_lock_2/sys/vm/vm_page.h	Tue Apr 20 20:09:45 2010	(r206910)
@@ -272,15 +272,30 @@ extern struct vpglocks vm_page_queue_loc
 #define vm_page_lock_queues()   mtx_lock(&vm_page_queue_mtx)
 #define vm_page_unlock_queues() mtx_unlock(&vm_page_queue_mtx)
 #define	vm_page_trylock_queues() mtx_trylock(&vm_page_queue_mtx)
-
 #ifdef VM_PAGE_LOCK
-#define	vm_page_lockptr(m)		pmap_page_lockptr(m)
+#define	vm_page_lockptr(m)			pmap_page_lockptr(m)
 #define	vm_page_lock_queues_assert_notowned()   mtx_assert(&vm_page_queue_mtx, MA_NOTOWNED)
-#define	vm_page_lock_assert_notowned(m)   vm_page_lock_assert((m), MA_NOTOWNED)
+#define	vm_page_lock_assert_notowned(m)   	vm_page_lock_assert((m), MA_NOTOWNED)
+#define	vm_page_lock_queues_cond(x)
+#define	vm_page_unlock_queues_cond(x)
 #else
 #define	vm_page_lockptr(m)		(&vm_page_queue_mtx)
 #define	vm_page_lock_queues_assert_notowned()
 #define	vm_page_lock_assert_notowned(m)  
+#define	vm_page_lock_queues_cond(x)			\
+	do {						\
+		if (x == FALSE) {			\
+			are_queues_locked = TRUE;	\
+			vm_page_lock_queues();		\
+		}					\
+	} while (0)
+#define	vm_page_unlock_queues_cond(x)			\
+	do {						\
+		if (x == TRUE) {			\
+			are_queues_locked = FALSE;	\
+			vm_page_unlock_queues();	\
+		}					\
+	} while (0)
 #endif
 #define	vm_page_lock(m)		mtx_lock(vm_page_lockptr((m)))
 #define	vm_page_unlock(m)	mtx_unlock(vm_page_lockptr((m)))


More information about the svn-src-user mailing list