PERFORCE change 98772 for review

Kip Macy kmacy at FreeBSD.org
Thu Jun 8 07:42:41 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=98772

Change 98772 by kmacy at kmacy_storage:sun4v_work_ifc on 2006/06/08 03:09:23

	a real fix for the previously patched issue
	modification of the static variables in vm_page_alloc_contig needs to be
	serialized
	this can be accomplished by moving the vm_page_queue mutex acquisition up a few lines

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pmap.h#15 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#64 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tsb.c#18 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#39 edit
.. //depot/projects/kmacy_sun4v/src/sys/vm/vm_contig.c#4 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pmap.h#15 (text+ko) ====

@@ -115,7 +115,6 @@
 extern	vm_offset_t virtual_avail;
 extern	vm_offset_t virtual_end;
 extern	vm_paddr_t msgbuf_phys;
-extern  struct mtx page_alloc_lock;
 
 
 static __inline int

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#64 (text+ko) ====

@@ -106,7 +106,6 @@
 int sparc64_nmemreg;
 
 extern vm_paddr_t mmu_fault_status_area;
-struct mtx page_alloc_lock;
 
 /*
  * First and last available kernel virtual addresses.
@@ -1106,7 +1105,6 @@
 		ctx_stack[ctx_stack_top] = ctx_stack_top;
 
 	mtx_init(&pmap_ctx_lock, "ctx lock", NULL, MTX_SPIN);
-	mtx_init(&page_alloc_lock, "page alloc", NULL, MTX_SPIN);
 
 	/*
 	 * Initialize the address space (zone) for the pv entries.  Set a

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tsb.c#18 (text+ko) ====

@@ -77,10 +77,8 @@
 
 	m = NULL;
 	while (m == NULL) {
-		mtx_lock_spin(&page_alloc_lock);
 		m = vm_page_alloc_contig(TSB_SIZE, phys_avail[0], 
 					 phys_avail[1], TSB_SIZE*PAGE_SIZE, (1UL<<34));
-		mtx_unlock_spin(&page_alloc_lock);
 		if (m == NULL) {
 			printf("vm_page_alloc_contig failed - waiting to retry\n");
 			VM_WAIT;

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#39 (text+ko) ====

@@ -179,10 +179,8 @@
 	m = NULL;
 
 	while (m == NULL) {
-		mtx_lock_spin(&page_alloc_lock);
 		m = vm_page_alloc_contig(HASH_SIZE, phys_avail[0], 
 					 phys_avail[1], PAGE_SIZE, (1UL<<34));
-		mtx_unlock_spin(&page_alloc_lock);
 		if (m == NULL) {
 			printf("vm_page_alloc_contig failed - waiting to retry\n");
 			VM_WAIT;
@@ -195,11 +193,9 @@
 	th->th_hashtable = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
 	m = NULL;
 	while (m == NULL) {
-		mtx_lock_spin(&page_alloc_lock);
 		m = vm_page_alloc(NULL, color++,
 		    VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
 		    VM_ALLOC_ZERO);
-		mtx_unlock_spin(&page_alloc_lock);
 
 		if (m == NULL) 
 			VM_WAIT;

==== //depot/projects/kmacy_sun4v/src/sys/vm/vm_contig.c#4 (text+ko) ====

@@ -398,6 +398,7 @@
 	vm_page_t pga = vm_page_array;
 	static vm_pindex_t np = 0;
 	static vm_pindex_t start = 0;
+	vm_pindex_t startl = 0;
 	int i, pass, pqtype;
 
 	size = npages << PAGE_SHIFT;
@@ -417,6 +418,7 @@
 	 * cached amount.
 	 */
 	for (pass = 0; pass < 2; pass++) {
+		vm_page_lock_queues();
 		if ((np == 0) || (np > npages)) {
 			if (atop(high) < vm_page_array_size)
 				start = atop(high) - npages + 1;
@@ -424,7 +426,6 @@
 				start = vm_page_array_size - npages + 1;
 		}
 		np = 0;
-		vm_page_lock_queues();
 retry:
 		start--;
 		/*
@@ -517,12 +518,13 @@
 			if (vm_contig_unqueue_free(m) != 0)
 				goto retry_page;
 		}
-		vm_page_unlock_queues();
 		/*
 		 * We've found a contiguous chunk that meets are requirements.
 		 */
 		np = npages;
-		return (&pga[start]);
+		startl = start;
+		vm_page_unlock_queues();
+		return (&pga[startl]);
 	}
 	return (NULL);
 }
@@ -584,7 +586,6 @@
 	vm_pindex_t npgs;
 
 	npgs = round_page(size) >> PAGE_SHIFT;
-	mtx_lock(&Giant);
 	if (vm_old_contigmalloc) {
 		ret = contigmalloc1(size, type, flags, low, high, alignment,
 		    boundary, kernel_map);
@@ -600,7 +601,6 @@
 		}
 		
 	}
-	mtx_unlock(&Giant);
 	malloc_type_allocated(type, ret == NULL ? 0 : npgs << PAGE_SHIFT);
 	return (ret);
 }


More information about the p4-projects mailing list