Subject: Sysmapsize too small on pmax install kernels
To: None <port-mips@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: port-mips
Date: 02/22/2001 17:21:27
Hi,

I tried to build a pmax snapshot, and during testing(!!) the INSTALL and
RAMDISK kernels panic'd with:

	panic: ubc_init: failed to map ubc_object

Turns out these kernels have "maxusers 8", and the Sysmap is not big
enough.  After some digging and shuffling, I'm running ok with this
patch:


Index: pmap.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/pmap.c,v
retrieving revision 1.117
diff -d -p -u -u -r1.117 pmap.c
--- pmap.c	2001/01/14 03:28:57	1.117
+++ pmap.c	2001/02/22 02:37:14
@@ -267,9 +267,19 @@ pmap_bootstrap()
 	 * Figure out how many PTE's are necessary to map the kernel.
 	 * We also reserve space for kmem_alloc_pageable() for vm_fork().
 	 */
-	Sysmapsize = (VM_PHYS_SIZE + ubc_nwins * ubc_winsize +
-		nbuf * MAXBSIZE + 16 * NCARGS + PAGER_MAP_SIZE) / NBPG +
-		(maxproc * UPAGES) + nkmempages;
+	Sysmapsize  = MAXBSIZE * nbuf;
+	Sysmapsize += nkmempages << PAGE_SHIFT;
+	Sysmapsize += PAGER_MAP_SIZE;
+	Sysmapsize += ubc_nwins * ubc_winsize;
+	Sysmapsize += (maxproc * UPAGES) << PAGE_SHIFT;
+	Sysmapsize += 16 * NCARGS;
+	Sysmapsize += 0x100000;				/* XXX XXX for anons (sizeof(struct vm_anon) * needed) */
+	Sysmapsize += 0x80000;				/* XXX XXX dynamic for uvm_page_rehash */
+	Sysmapsize += VM_PHYS_SIZE;
+	Sysmapsize += MAXBSIZE;
+	Sysmapsize += nkmempages * sizeof(struct kmemusage);
+	/* XXX slop??? */
+	Sysmapsize /= NBPG;
 
 #ifdef SYSVSHM
 	Sysmapsize += shminfo.shmall;


but this is pretty fugly.  The list above is in order of decreasing size
(for a pmax INSTALL kernel) - the old Sysmapsize calculation is running
short with anons and the page hash tables.  Both of these can grow - do
we need to add some extra slop in here to be safe?  Any suggestions on
cleaning this up somehow?

Chuck Silvers suggested life on mips ports would be easier if we just
had a pmap_grow_kernel() but that looks (to me) to be non-trivial to
add.

FWIW, here's the Sysmapsize values I've been seeing:

			old calc	new calc
	INSTALL		59608		60020
	GENERIC		62424		62836

Secondary question - both mips and alpha have the "+= shminfo.shmall"
addition - should this really be "+= shminfo.shmall / NBPG"?

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/