Subject: Re: maxusers and its progeny
To: None <Chris_G_Demetriou@NIAGARA.NECTAR.CS.CMU.EDU>
From: David Paul Zimmerman <dpz@apple.com>
List: port-alpha
Date: 01/04/1996 22:45:11
Chris & Co.:

>as i recall (i looked at it a while ago), it increases linearly with
>maxusers, and with maxusers == 16 it's ~1G and maxusers == 32 it's
>~2G.  (something like that; i know that i was running into 'int'
>signedness problems, and i think it was while trying maxusers == 32.)
>
>the kernel only allows 8G of KV-space, max, and i've not tried to boot
>with anything larger than '32'.  as i recall, '32' worked, though.

Using the stock 951220 code and an unexceptional config file, a maxusers 
of 32 gets me a panic "pmap_enter_ptpage: can't get KPT page" just after 
loading the kernel.  As I mentioned, much higher maxusers cause it to 
simply hang around that same point.

Apparently the live version of what I pseudocoded, while in fact letting 
the system successfully boot with a maxusers of 250, causes it to panic 
not a long time later in vm/vm_kern.c/kmem_malloc() with "kmem_malloc: 
kmem_map too small".  I've included the diffs at the end of this message 
for humor value if nothing else (the kernel config file has a line 
"options SWAP_RATIO=4").

Having spent younger time in Berkeley kernels playing with tty and IP 
code, this is new territory for me, so please bear with me.  Am I under a 
misconception thinking that the necessary number of KPT entries is 
realistically bounded by available physical+virtual memory?  Or am I just 
making too much of a coding goof, maybe just missed a related case that 
needs a bit 'o rewriting too?

One more question -- I've found the derivations of the numbers you 
mentioned except for the 8GB.  Is that an explicit or implicit limit or 
limitation?  It certainly doesn't fit in a 32 bit int, so I'm curious.

dp

*** pmap.c	Thu Jan  4 22:31:38 1996
--- pmap.c.dpz	Thu Jan  4 16:55:28 1996
***************
*** 314,320 ****
--- 314,325 ----
  	 */
  	Sysmapsize = (VM_KMEM_SIZE + VM_MBUF_SIZE + VM_PHYS_SIZE +
  		nbuf * MAXBSIZE + 16 * NCARGS) / NBPG + 512 + 256;
+ #ifdef SWAP_RATIO
+ 	Sysmapsize += ((physmem * (1 + SWAP_RATIO)) >> (PGSHIFT - PTESHIFT))
+ 		    + (physmem * (1 + SWAP_RATIO));
+ #else
          Sysmapsize += maxproc * (btoc(ALPHA_STSIZE) + 
btoc(ALPHA_MAX_PTSIZE));
+ #endif
  
  #ifdef SYSVSHM
  	Sysmapsize += shminfo.shmall;
***************
*** 508,520 ****
--- 513,533 ----
  	/*
  	 * Allocate the segment table map
  	 */
+ #ifdef SWAP_RATIO
+ 	s = (ctob(physmem) * (1 + SWAP_RATIO)) >> (PGSHIFT - PTESHIFT);
+ #else
  	s = maxproc * ALPHA_STSIZE;
+ #endif
  	st_map = kmem_suballoc(kernel_map, &addr, &addr2, s, TRUE);
  
  	/*
  	 * Allocate the page table map
  	 */
+ #ifdef SWAP_RATIO
+ 	s = ctob(physmem) * (1 + SWAP_RATIO);
+ #else
  	s = maxproc * ALPHA_MAX_PTSIZE;			/* XXX limit it */
+ #endif
  	pt_map = kmem_suballoc(kernel_map, &addr, &addr2, s, TRUE);
  	
  	/*