Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jul 2002 16:20:27 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 14163 for review
Message-ID:  <200207122320.g6CNKRid027493@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=14163

Change 14163 by peter@peter_xeon on 2002/07/12 16:20:07

	make it possible for pagezero to run outside of Giant.
	- add locking state assertions to vm_pageq.c
	- lock the vm_pageq_add stuff from early boot to not trip these
	- allow vm_page_flag_set() etc to work on pages not in the
	  remaining giant protected queues.  ie: not required for
	  PQ_NONE or PQ_FREE.  I hope. :-)  It should probably only
	  be exempt for PQ_NONE.

Affected files ...

.. //depot/projects/pmap/sys/vm/vm_page.c#5 edit
.. //depot/projects/pmap/sys/vm/vm_pageq.c#5 edit

Differences ...

==== //depot/projects/pmap/sys/vm/vm_page.c#5 (text+ko) ====

@@ -303,6 +303,7 @@
 	 * last rather than first.  On large-memory machines, this avoids
 	 * the exhaustion of low physical memory before isa_dmainit has run.
 	 */
+	mtx_lock_spin(&vm_page_queue_free_mtx);
 	cnt.v_page_count = 0;
 	cnt.v_free_count = 0;
 	for (i = 0; phys_avail[i + 1] && npages > 0; i += 2) {
@@ -316,6 +317,7 @@
 			pa += PAGE_SIZE;
 		}
 	}
+	mtx_unlock_spin(&vm_page_queue_free_mtx);
 	return (vaddr);
 }
 
@@ -341,14 +343,22 @@
 void
 vm_page_flag_set(vm_page_t m, unsigned short bits)
 {
-	GIANT_REQUIRED;
+
+#ifdef INVARIANTS
+	if (m->queue >= PQ_INACTIVE)
+		mtx_assert(&Giant, MA_OWNED);
+#endif
 	m->flags |= bits;
 } 
 
 void
 vm_page_flag_clear(vm_page_t m, unsigned short bits)
 {
-	GIANT_REQUIRED;
+
+#ifdef INVARIANTS
+	if (m->queue >= PQ_INACTIVE)
+		mtx_assert(&Giant, MA_OWNED);
+#endif
 	m->flags &= ~bits;
 }
 

==== //depot/projects/pmap/sys/vm/vm_pageq.c#5 (text+ko) ====

@@ -26,6 +26,22 @@
 struct vpgqueues vm_page_queues[PQ_COUNT];
 static struct mtx vm_pageq_mtx[PQ_COUNT];
 
+
+#ifdef INVARIANTS
+static __inline void
+vm_pageq_lockcheck(int queue)
+{
+
+	if (queue >= PQ_FREE && queue < PQ_INACTIVE)
+		mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
+	else
+		mtx_assert(&Giant, MA_OWNED);
+}
+#define LOCKCHECK(queue) vm_pageq_lockcheck(queue)
+#else
+#define LOCKCHECK(queue) do { } while(0)
+#endif
+
 void
 vm_pageq_init(void) 
 {
@@ -108,8 +124,7 @@
 {
 	vm_page_t m;
 
-	GIANT_REQUIRED;
-
+	LOCKCHECK(PQ_FREE);
 	++cnt.v_page_count;
 	m = PHYS_TO_VM_PAGE(pa);
 	m->phys_addr = pa;
@@ -155,8 +170,8 @@
 	int queue = m->queue;
 	struct vpgqueues *pq;
 
-	GIANT_REQUIRED;
 	if (queue != PQ_NONE) {
+		LOCKCHECK(queue);
 		m->queue = PQ_NONE;
 		pq = &vm_page_queues[queue];
 		TAILQ_REMOVE(&pq->pl, m, pageq);
@@ -195,9 +210,8 @@
 	vm_page_t m = NULL;
 	struct vpgqueues *pq;
 
-	GIANT_REQUIRED;
+	LOCKCHECK(basequeue);
 	pq = &vm_page_queues[basequeue];
-
 	/*
 	 * Note that for the first loop, index+i and index-i wind up at the
 	 * same place.  Even though this is not totally optimal, we've already
@@ -217,10 +231,9 @@
 vm_page_t
 vm_pageq_find(int basequeue, int index, boolean_t prefer_zero)
 {
-        vm_page_t m;
+	vm_page_t m;
 
-	GIANT_REQUIRED;
-
+	LOCKCHECK(basequeue);
 #if PQ_L2_SIZE > 1
         if (prefer_zero) {
                 m = TAILQ_LAST(&vm_page_queues[basequeue+index].pl, pglist);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207122320.g6CNKRid027493>