6377034 setting physmem in /etc/system does not have desired effect on x86
authorkchow
Sun, 12 Feb 2006 20:51:59 -0800
changeset 1417 fa316336e215
parent 1416 cfa71a1e49b3
child 1418 f5ab79eb79c0
6377034 setting physmem in /etc/system does not have desired effect on x86 6382469 zfs_map() is not initializing all fields in segvn_crargs_t on call to as_map/segvn_create
usr/src/uts/common/conf/param.c
usr/src/uts/common/fs/zfs/zfs_vnops.c
usr/src/uts/i86pc/os/startup.c
--- a/usr/src/uts/common/conf/param.c	Sun Feb 12 19:23:23 2006 -0800
+++ b/usr/src/uts/common/conf/param.c	Sun Feb 12 20:51:59 2006 -0800
@@ -20,7 +20,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -538,10 +538,19 @@
 	 * Note: 2^20 is a meg; shifting right by (20 - PAGESHIFT)
 	 * converts pages to megs without integer overflow.
 	 */
+#if defined(__sparc)
 	if (physmem > original_physmem) {
 		physmem = original_physmem;
 		cmn_err(CE_NOTE, "physmem limited to %ld", physmem);
 	}
+#else
+	if (physmem != original_physmem) {
+		cmn_err(CE_NOTE, "physmem cannot be modified to 0x%lx"
+		    " via /etc/system. Please use eeprom(1M) instead.",
+		    physmem);
+		physmem = original_physmem;
+	}
+#endif
 	if (maxusers == 0) {
 		pgcnt_t physmegs = physmem >> (20 - PAGESHIFT);
 		pgcnt_t virtmegs = vmem_size(heap_arena, VMEM_FREE) >> 20;
--- a/usr/src/uts/common/fs/zfs/zfs_vnops.c	Sun Feb 12 19:23:23 2006 -0800
+++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c	Sun Feb 12 20:51:59 2006 -0800
@@ -3299,6 +3299,8 @@
 	vn_a.cred = cr;
 	vn_a.amp = NULL;
 	vn_a.flags = flags & ~MAP_TYPE;
+	vn_a.szc = 0;
+	vn_a.lgrp_mem_policy_flags = 0;
 
 	error = as_map(as, *addrp, len, segvn_create, &vn_a);
 
--- a/usr/src/uts/i86pc/os/startup.c	Sun Feb 12 19:23:23 2006 -0800
+++ b/usr/src/uts/i86pc/os/startup.c	Sun Feb 12 20:51:59 2006 -0800
@@ -977,10 +977,13 @@
 	 * the computed value unless it is larger than the real
 	 * amount of memory on hand.
 	 */
-	if (physmem == 0 || physmem > npages)
+	if (physmem == 0 || physmem > npages) {
 		physmem = npages;
-	else
+	} else if (physmem < npages) {
+		cmn_err(CE_WARN, "limiting physmem to 0x%lx of"
+		    " 0x%lx available pages", physmem, npages);
 		npages = physmem;
+	}
 	PRM_DEBUG(physmem);
 
 	/*
@@ -1674,44 +1677,6 @@
 	p0_va = i86devmap(0, 1, PROT_READ);
 	PRM_DEBUG(p0_va);
 
-	/*
-	 * If the following is true, someone has patched phsymem to be less
-	 * than the number of pages that the system actually has.  Remove
-	 * pages until system memory is limited to the requested amount.
-	 * Since we have allocated page structures for all pages, we
-	 * correct the amount of memory we want to remove by the size of
-	 * the memory used to hold page structures for the non-used pages.
-	 */
-	if (physmem < npages) {
-		uint_t diff;
-		offset_t off;
-		struct page *pp;
-		caddr_t rand_vaddr;
-		struct seg kseg;
-
-		cmn_err(CE_WARN, "limiting physmem to %lu pages", physmem);
-
-		off = 0;
-		diff = npages - physmem;
-		diff -= mmu_btopr(diff * sizeof (struct page));
-		kseg.s_as = &kas;
-		while (diff--) {
-			rand_vaddr = (caddr_t)
-			    (((uintptr_t)&unused_pages_vp >> 7) ^
-			    (uintptr_t)((u_offset_t)off >> MMU_PAGESHIFT));
-			pp = page_create_va(&unused_pages_vp, off, MMU_PAGESIZE,
-				PG_WAIT | PG_EXCL, &kseg, rand_vaddr);
-			if (pp == NULL) {
-				panic("limited physmem too much!");
-				/*NOTREACHED*/
-			}
-			page_io_unlock(pp);
-			page_downgrade(pp);
-			availrmem--;
-			off += MMU_PAGESIZE;
-		}
-	}
-
 	cmn_err(CE_CONT, "?mem = %luK (0x%lx)\n",
 	    physinstalled << (MMU_PAGESHIFT - 10), ptob(physinstalled));
 
@@ -2549,6 +2514,12 @@
 	} else {
 		segmapfreelists = (int)lvalue;
 	}
+
+	if ((BOP_GETPROPLEN(bootops, "physmem") <= sizeof (prop)) &&
+	    (BOP_GETPROP(bootops, "physmem", prop) >= 0) &&
+	    (kobj_getvalue(prop, &lvalue) != -1)) {
+		physmem = (uintptr_t)lvalue;
+	}
 }
 
 /*