PERFORCE change 98351 for review

John Baldwin jhb at FreeBSD.org
Fri Jun 2 16:31:53 UTC 2006


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

Change 98351 by jhb at jhb_mutex on 2006/06/02 16:29:50

	Move the vm.blacklist handling up a layer so that we only try to
	look up the tunable once during boot instead of once for every
	memory page in the system.  This should make Kip happy.

Affected files ...

.. //depot/projects/smpng/sys/vm/vm_page.c#75 edit
.. //depot/projects/smpng/sys/vm/vm_pageq.c#19 edit

Differences ...

==== //depot/projects/smpng/sys/vm/vm_page.c#75 (text+ko) ====

@@ -158,6 +158,36 @@
 }
 
 /*
+ *	vm_page_blacklist_lookup:
+ *
+ *	See if a physical address in this page has been listed
+ *	in the blacklist tunable.  Entries in the tunable are
+ *	separated by spaces or commas.  If an invalid integer is
+ *	encountered then the rest of the string is skipped.
+ */
+static int
+vm_page_blacklist_lookup(char *list, vm_paddr_t pa)
+{
+	vm_paddr_t bad;
+	char *cp, *pos;
+
+	for (pos = list; *pos != '\0'; pos = cp) {
+		bad = strtoq(pos, &cp, 0);
+		if (*cp != '\0') {
+			if (*cp == ' ' || *cp == ',') {
+				cp++;
+				if (cp == pos)
+					continue;
+			} else
+				break;
+		}
+		if (pa == trunc_page(bad))
+			return (1);
+	}
+	return (0);
+}
+
+/*
  *	vm_page_startup:
  *
  *	Initializes the resident memory module.
@@ -177,6 +207,7 @@
 	vm_paddr_t pa;
 	int nblocks;
 	vm_paddr_t last_pa;
+	char *list;
 
 	/* the biggest memory array is the second group of pages */
 	vm_paddr_t end;
@@ -293,14 +324,23 @@
 	 */
 	cnt.v_page_count = 0;
 	cnt.v_free_count = 0;
+	list = getenv("vm.blacklist");
 	for (i = 0; phys_avail[i + 1] && npages > 0; i += 2) {
 		pa = phys_avail[i];
 		last_pa = phys_avail[i + 1];
 		while (pa < last_pa && npages-- > 0) {
+			if (list != NULL &&
+			    vm_page_blacklist_lookup(list, pa)) {
+				printf("Skipping page with pa 0x%jx\n",
+				    (uintmax_t)pa);
+
+				continue;
+			}
 			vm_pageq_add_new_page(pa);
 			pa += PAGE_SIZE;
 		}
 	}
+	freeenv(list);
 	return (vaddr);
 }
 

==== //depot/projects/smpng/sys/vm/vm_pageq.c#19 (text+ko) ====

@@ -191,37 +191,7 @@
 vm_page_t
 vm_pageq_add_new_page(vm_paddr_t pa)
 {
-	vm_paddr_t bad;
 	vm_page_t m;
-	char *cp, *list, *pos;
-
-	/*
-	 * See if a physical address in this page has been listed
-	 * in the blacklist tunable.  Entries in the tunable are
-	 * separated by spaces or commas.  If an invalid integer is
-	 * encountered then the rest of the string is skipped.
-	 */
-	if (testenv("vm.blacklist")) {
-		list = getenv("vm.blacklist");
-		for (pos = list; *pos != '\0'; pos = cp) {
-			bad = strtoq(pos, &cp, 0);
-			if (*cp != '\0') {
-				if (*cp == ' ' || *cp == ',') {
-					cp++;
-					if (cp == pos)
-						continue;
-				} else
-					break;
-			}
-			if (pa == trunc_page(bad)) {
-				printf("Skipping page with pa 0x%jx\n",
-				    (uintmax_t)pa);
-				freeenv(list);
-				return (NULL);
-			}
-		}
-		freeenv(list);
-	}
 
 	atomic_add_int(&cnt.v_page_count, 1);
 	m = PHYS_TO_VM_PAGE(pa);


More information about the p4-projects mailing list