Subject: moving allocsys() into MI part of kernel
To: None <tech-kern@netbsd.org>
From: Luke Mewburn <lukem@netbsd.org>
List: tech-kern
Date: 05/09/1999 03:00:40
Hi all...

Whilst looking at which ports supported the `BUFCACHE' option (with
intent to convert the remaining ports), I noticed that most ports
had a MD allocsys() function, which (amongst other things) calculates
and then allocates the memory to be used by the buffer cache.

I decided to see how hard it would be to make this function MI; 
it was fairly simple.

I created a new file - sys/kern/kern_allocsys.c - where the MI
version of the allocsys() function goes. (It's only there because
I'm not familiar enough with the kernel file layout to come up
with a better location)

The various machdep.c's have been modified to take advantage of the
unified function.

Another modification I did was to implement format_memory(), which
returns a pointer to a static buffer containing the given number
formatted as
	"%qd KB (%qd bytes)", x / 1024, x
The startup messages which display memory are now consistent for each
port, and display something like:
	total memory = 65152 KB (66715648 bytes)
	avail memory = 45428 KB (46518272 bytes)
	using 2822 buffers containing 16288 KB (16678912 bytes) of memory

Some comments:
	* I've only compiled this for the i386; other ports (notably
	  the sparc and alpha) will need a little tweaking.

	* The arm32, i386 and pc532 define VM_MAX_KERNEL_BUF, which
	  nbuf is checked against to prevent wasting too much KVM on
	  a sparsely filled buffer cache. Either the other ports
	  should defined this in <machine/vm_param.h>, or the
	  code which checks that in allocsys() should wrap that test
	  in #ifdef VM_MAX_KERNEL_BUF.

	* The sparc allocsys() had a different way of ensuring that
	  the KVM wasn't wasted too much, but it looked to be a
	  variation on the VM_MAX_KERNEL_BUF above, so this wasn't
	  retained.
	  The check for CPU_ISSUN4C not using more than (128 *
	  (65536/MAXBSIZE)) bufpages was retained in the MI function.

	* The alpha allocsys() also allocated `mchkinfo_all_cpus'.
	  This has been put into the MI function #ifdef __alpha__.
	  This is a tad ugly, but I'm not sure of a better way.

	* The sparc64 allocsys() also allocated `dvmamap'.  This
	  has been put into the MI function #ifdef __sparc64__.
	  This is a tad ugly, but I'm not sure of a better way.

	* The amiga, atari, mac68k and x68k didn't have an allocsys()
	  function; the work was directly done in cpu_startup()
	  (or equivalent). This looked to be an older method.

	* The various mips ports already had a cpu dependant
	  allocsys() (i.e, shared amongst the mips machines)

	* The default buffer cache for some ports was 10% of RAM,
	  others it was 10% of the first 2MB and 5% of the rest.
	  I've just made the default 10% for all ports.

	* I'm sure there's a better place than kern/kern_allocsys()
	  for these functions, but I'm not sure where.

	* On a similar note, the two functions are extern prototyped
	  in each machdep.c because I didn't know the appropriate
	  header file to put this in.

I'd like to commit this in, unless there's good reasons against it.

Any comments/suggestions/improvements on what I've done?

Index: arch/alpha/alpha/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.172
diff -p -c -r1.172 machdep.c
*** machdep.c	1999/04/29 03:02:20	1.172
--- machdep.c	1999/05/08 12:04:14
***************
*** 64,70 ****
   * rights to redistribute these changes.
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_multiprocessor.h"
  #include "opt_pmap_new.h"
--- 64,69 ----
***************
*** 78,84 ****
  #include "opt_iso.h"
  #include "opt_ns.h"
  #include "opt_natm.h"
- #include "opt_sysv.h"
  
  #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
  
--- 77,82 ----
*************** __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
*** 109,123 ****
  #include <sys/core.h>
  #include <sys/kcore.h>
  #include <machine/kcore.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <sys/mount.h>
  #include <sys/syscallargs.h>
--- 107,112 ----
*************** extern void comsoft __P((void));
*** 193,218 ****
  vm_map_t exec_map = NULL;
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
- 
- /*
-  * Declare these as initialized data so we can patch them.
-  */
- int	nswbuf = 0;
- #ifdef	NBUF
- int	nbuf = NBUF;
- #else
- int	nbuf = 0;
- #endif
- 
- #ifndef	BUFPAGES
- #define BUFPAGES 0
- #endif
- #ifndef BUFCACHE
- #define BUFCACHE 10
- #endif
  
! int	bufpages = BUFPAGES;	/* optional hardwired count */
! int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
  
  caddr_t msgbufaddr;
  
--- 182,191 ----
  vm_map_t exec_map = NULL;
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  caddr_t msgbufaddr;
  
*************** int	alpha_unaligned_sigbus = 0;	/* don't
*** 280,286 ****
  phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];	/* low size bits overloaded */
  int	mem_cluster_cnt;
  
- caddr_t	allocsys __P((caddr_t));
  int	cpu_dump __P((void));
  int	cpu_dumpsize __P((void));
  u_long	cpu_dump_mempagecnt __P((void));
--- 253,258 ----
*************** nobootinfo:
*** 900,970 ****
  	}
  }
  
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and the call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)ALIGN((name)+(num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate.
- 	 * We allocate bufcache % of memory for buffer space.  Insure a
- 	 * minimum of 16 buffers.  We allocate 1/2 as many swap buffer
- 	 * headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = physmem / CLSIZE * bufcache / 100;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	/*
- 	 * There appears to be a correlation between the number
- 	 * of processor slots defined in the HWRPB and the whami
- 	 * value that can be returned.
- 	 */
- 	valloc(mchkinfo_all_cpus, struct mchkinfo, hwrpb->rpb_pcs_cnt);
- 
- 	return (v);
- #undef valloc
- }
- 
  void
  consinit()
  {
--- 872,877 ----
*************** cpu_startup()
*** 1019,1032 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real mem = %lu (%lu reserved for PROM, %lu used by NetBSD)\n",
! 	    ((psize_t) totalphysmem << (psize_t) PAGE_SHIFT),
! 	    ptoa(resvmem), ptoa(physmem));
  	if (unusedmem)
! 		printf("WARNING: unused memory = %d bytes\n", ctob(unusedmem));
  	if (unknownmem)
! 		printf("WARNING: %d bytes of memory with unknown purpose\n",
! 		    ctob(unknownmem));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
--- 926,941 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s\n",
! 	    format_memory(totalphysmem << PAGE_SHIFT));
! 	printf("(%s reserved for PROM, ", format_memory(ptoa(resvmem)));
! 	printf("%s used by NetBSD)\n", format_memory(ptoa(physmem)));
  	if (unusedmem)
! 		printf("WARNING: unused memory = %s\n",
! 		    format_memory(ctob(unusedmem)));
  	if (unknownmem)
! 		printf("WARNING: %s of memory with unknown purpose\n",
! 		    format_memory(ctob(unknownmem)));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
*************** cpu_startup()
*** 1101,1107 ****
  #if defined(DEBUG)
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", (long)ptoa(uvmexp.free));
  #if 0
  	{
  		extern u_long pmap_pages_stolen;
--- 1010,1016 ----
  #if defined(DEBUG)
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
  #if 0
  	{
  		extern u_long pmap_pages_stolen;
*************** cpu_startup()
*** 1109,1116 ****
  		    pmap_pages_stolen * PAGE_SIZE);
  	}
  #endif
! 	printf("using %ld buffers containing %ld bytes of memory\n",
! 		(long)nbuf, (long)(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 1018,1025 ----
  		    pmap_pages_stolen * PAGE_SIZE);
  	}
  #endif
! 	printf("using %ld buffers containing %s of memory\n",
! 	    (long)nbuf, format_memory((bufpages * CLBYTES)));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
Index: arch/amiga/amiga/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amiga/amiga/machdep.c,v
retrieving revision 1.135
diff -p -c -r1.135 machdep.c
*** machdep.c	1999/04/26 22:46:44	1.135
--- machdep.c	1999/05/08 12:04:15
***************
*** 42,55 ****
   *	@(#)machdep.c	7.16 (Berkeley) 6/3/91
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_inet.h"
  #include "opt_atalk.h"
  #include "opt_iso.h"
  #include "opt_ns.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 42,53 ----
***************
*** 75,89 ****
  #include <sys/syscallargs.h>
  #include <sys/core.h>
  #include <sys/kcore.h>
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
  #include <net/netisr.h>
  #define	MAXMEM	64*1024*CLSIZE	/* XXX - from cmap.h */
  #include <vm/vm.h>
--- 73,78 ----
*************** vm_map_t exec_map = NULL;  
*** 174,193 ****
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  caddr_t	msgbufaddr;
  vm_offset_t msgbufpa;
  
--- 163,172 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
! 
  caddr_t	msgbufaddr;
  vm_offset_t msgbufpa;
  
*************** void
*** 258,264 ****
  cpu_startup()
  {
  	register unsigned i;
! 	register caddr_t v, firstaddr;
  	int base, residual;
  #ifdef DEBUG
  	extern int pmapdebug;
--- 237,243 ----
  cpu_startup()
  {
  	register unsigned i;
! 	caddr_t v;
  	int base, residual;
  #ifdef DEBUG
  	extern int pmapdebug;
*************** cpu_startup()
*** 289,377 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real  mem = %d (%d pages)\n", ctob(physmem), ctob(physmem)/NBPG);
  
- 	/*
- 	 * Allocate space for system data structures.
- 	 * The first available real memory address is in "firstaddr".
- 	 * The first available kernel virtual address is in "v".
- 	 * As pages of kernel virtual memory are allocated, "v" is incremented.
- 	 * As pages of memory are allocated and cleared,
- 	 * "firstaddr" is incremented.
- 	 * An index into the kernel page table corresponding to the
- 	 * virtual memory address maintained in "v" is kept in "mapaddr".
- 	 */
- 	/*
- 	 * Make two passes.  The first pass calculates how much memory is
- 	 * needed and allocates it.  The second pass assigns virtual
- 	 * addresses to the various data structures.
- 	 */
- 	firstaddr = 0;
- again:
- 	v = (caddr_t)firstaddr;
- 
- #define	valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
- #define	valloclim(name, type, num, lim) \
- 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
- /*	valloc(cfree, struct cblock, nclist); */
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 	/*
- 	 * Determine how many buffers to allocate. We allocate
- 	 * the BSD standard of use 10% of memory for the first 2 Meg,
- 	 * 5% of remaining. Insure a minimum of 16 buffers.
- 	 * We allocate 3/4 as many swap buffer headers as file i/o buffers.
- 	 */
-   	if (bufpages == 0) {
- 		if (physmem < btoc(2 * 1024 * 1024))
- 			bufpages = physmem / (10 * CLSIZE);
- 		else
- 			bufpages = (btoc(2 * 1024 * 1024) + physmem) /
- 			    (20 * CLSIZE);
- 	}
- 
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf * 3 / 4) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	/*
- 	 * End of first pass, size has been calculated so allocate memory
- 	 */
- 	if (firstaddr == 0) {
- 		size = (vm_size_t)(v - firstaddr);
- 		firstaddr = (caddr_t)uvm_km_zalloc(kernel_map,
- 		    round_page(size));
- 		if (firstaddr == 0)
- 			panic("startup: no room for tables");
- 		goto again;
- 	}
  	/*
! 	 * End of second pass, addresses have been assigned
  	 */
! 	if ((vm_size_t)(v - firstaddr) != size)
  		panic("startup: table size inconsistency");
  
  	/*
--- 268,283 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
! 	 * Find out how much space we need, allocate it,
! 	 * and then give everything true virtual addresses.
  	 */
! 	size = (vm_size_t)allocsys((caddr_t)0);
! 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! 		panic("startup: no room for tables");
! 	if (allocsys(v) - v != size)
  		panic("startup: table size inconsistency");
  
  	/*
*************** again:
*** 451,460 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld (%ld pages)\n", ptoa(uvmexp.free),
! 	    ptoa(uvmexp.free)/NBPG);
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	    nbuf, bufpages * CLBYTES);
  	
  	/*
  	 * display memory configuration passed from loadbsd
--- 357,365 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  	
  	/*
  	 * display memory configuration passed from loadbsd
Index: arch/arm32/arm32/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm32/arm32/machdep.c,v
retrieving revision 1.67
diff -p -c -r1.67 machdep.c
*** machdep.c	1999/04/26 22:46:44	1.67
--- machdep.c	1999/05/08 12:04:16
***************
*** 40,50 ****
   * Created      : 17/09/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_compat_netbsd.h"
  #include "opt_md.h"
  #include "opt_pmap_debug.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 40,48 ----
***************
*** 63,78 ****
  #include <sys/sysctl.h>
  #include <sys/syscallargs.h>
  
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
- 
  #include <dev/cons.h>
  
  #include <machine/db_machdep.h>
--- 61,66 ----
*************** vm_map_t exec_map = NULL;
*** 98,103 ****
--- 86,95 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
+ extern caddr_t		 allocsys __P((caddr_t));
+ extern const char	*format_memory __P((int64_t));
+ extern int		 nbuf, nswbuf;
+ 
  extern int physmem;
  
  #ifndef PMAP_STATIC_L1S
*************** int kernel_debug = 0;
*** 126,151 ****
  
  struct user *proc0paddr;
  
- /*
-  * Declare these as initialized data so we can patch them.
-  */
- int	nswbuf = 0;
- #ifdef	NBUF
- int	nbuf = NBUF;
- #else
- int	nbuf = 0;
- #endif
- #ifdef	BUFPAGES
- int	bufpages = BUFPAGES;
- #else
- int	bufpages = 0;
- #endif
- #ifdef BUFCACHE
- int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
- #else
- int	bufcache = 0;		/* fallback to old algorithm */
- #endif
- 
  int cold = 1;
  
  /* Prototypes */
--- 118,123 ----
*************** void map_entry_ro	__P((vm_offset_t pt, v
*** 161,167 ****
  
  void pmap_bootstrap		__P((vm_offset_t kernel_l1pt));
  u_long strtoul			__P((const char *s, char **ptr, int base));
- caddr_t allocsys		__P((caddr_t v));
  void data_abort_handler		__P((trapframe_t *frame));
  void prefetch_abort_handler	__P((trapframe_t *frame));
  void zero_page_readonly		__P((void));
--- 133,138 ----
*************** cpu_startup()
*** 411,417 ****
  	 * not be buffered).
  	 */
  	printf(version);
! 	printf("real mem  = %d\n", arm_page_to_byte(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 382,388 ----
  	 * not be buffered).
  	 */
  	printf(version);
! 	printf("total memory = %s\n", format_memory(arm_page_to_byte(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 420,426 ****
  	size = allocsys((caddr_t)0);
  	sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size));
  	if (sysbase == 0)
! 		panic("cpu_startup: no room for system tables %d bytes required", (u_int)size);
  	if ((caddr_t)((allocsys(sysbase) - sysbase)) != size)
  		panic("cpu_startup: system table size inconsistency");
  
--- 391,399 ----
  	size = allocsys((caddr_t)0);
  	sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size));
  	if (sysbase == 0)
! 		panic(
! 		    "cpu_startup: no room for system tables; %d bytes required",
! 		    (u_int)size);
  	if ((caddr_t)((allocsys(sysbase) - sysbase)) != size)
  		panic("cpu_startup: system table size inconsistency");
  
*************** cpu_startup()
*** 489,497 ****
  		callout[loop - 1].c_next = &callout[loop];
  	callout[loop - 1].c_next = NULL;
  
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	    nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 462,470 ----
  		callout[loop - 1].c_next = &callout[loop];
  	callout[loop - 1].c_next = NULL;
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
*************** cpu_startup()
*** 506,608 ****
  	    (vm_offset_t)(kernel_pmap)->pm_pdir);
  	    
  	proc0.p_md.md_regs = (struct trapframe *)curpcb->pcb_sp - 1;
- }
- 
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- 
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	(caddr_t)(name) = (type *)v; \
- 	v = (caddr_t)((name) + (num));
- 
- 	valloc(callout, struct callout, ncallout);
- 
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
-                                                                          
- 	/*
- 	 * If necessary, determine the number of pages to use for the
- 	 * buffer cache.  We allocate 1/2 as many swap buffer headers
- 	 * as file I/O buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {		/* use old algorithm */
- 			/*
- 			 * Determine how many buffers to allocate. We use 10%
- 			 * of the first 2MB of memory, and 5% of the rest, with
- 			 * a minimum of 16 buffers.
- 			 */
- 			if (physmem < arm_byte_to_page(2 * 1024 * 1024))
- 				bufpages = physmem / (10 * CLSIZE);
- 			else
- 				bufpages = (arm_byte_to_page(2 * 1024 * 1024)
- 					 + physmem) / (20 * CLSIZE);
- 		} else {
- 			/*
- 			 * Set size of buffer cache to physmem/bufcache * 100
- 			 * (i.e., bufcache % of physmem).
- 			 */
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf(
- 		"warning: unable to set bufcache to %d%% of RAM, using 10%%",
- 				    bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages= physmem / (CLSIZE * 100) * bufcache;
- 		}
- 	}
- #ifdef DIAGNOSTIC
- 	if (bufpages == 0)
- 		panic("bufpages = 0\n");
- #endif
- 
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	/*
- 	 * XXX stopgap measure to prevent wasting too much KVM on
- 	 * the sparsely filled buffer cache.
- 	 */
- 	if (nbuf * MAXBSIZE > VM_MAX_KERNEL_BUF)
- 		nbuf = VM_MAX_KERNEL_BUF / MAXBSIZE;
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) & ~1;       /* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;           /* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	return(v);
  }
  
  #ifndef FOOTBRIDGE
--- 479,484 ----
Index: arch/atari/atari/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/atari/atari/machdep.c,v
retrieving revision 1.81
diff -p -c -r1.81 machdep.c
*** machdep.c	1999/04/26 22:46:45	1.81
--- machdep.c	1999/05/08 12:04:18
***************
*** 42,55 ****
   *	@(#)machdep.c	7.16 (Berkeley) 6/3/91
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_atalk.h"
  #include "opt_inet.h"
  #include "opt_iso.h"
  #include "opt_ns.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 42,53 ----
***************
*** 73,87 ****
  #include <sys/queue.h>
  #include <sys/mount.h>
  #include <sys/syscallargs.h>
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
  #include <net/netisr.h>
  #define	MAXMEM	64*1024*CLSIZE	/* XXX - from cmap.h */
  #include <vm/vm.h>
--- 71,76 ----
*************** vm_map_t exec_map = NULL;  
*** 113,131 ****
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef BUFCACHE
! int	bufchache = BUFCACHE;
! #else
! int	bufcache = 0;
! #endif
  
  caddr_t	msgbufaddr;
  vaddr_t	msgbufpa;
--- 102,110 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  caddr_t	msgbufaddr;
  vaddr_t	msgbufpa;
*************** cpu_startup()
*** 181,187 ****
  {
  	extern	 void		etext __P((void));
  	register unsigned	i;
! 	register caddr_t	v, firstaddr;
  		 int		base, residual;
  		 u_long		avail_mem;
  
--- 160,166 ----
  {
  	extern	 void		etext __P((void));
  	register unsigned	i;
! 		 caddr_t	v;
  		 int		base, residual;
  		 u_long		avail_mem;
  
*************** cpu_startup()
*** 214,319 ****
  	 */
  	printf(version);
  	identifycpu();
- 
- 	printf("real  mem = %ld (%ld pages)\n", mem_size, mem_size/NBPG);
  
! 	/*
! 	 * Allocate space for system data structures.
! 	 * The first available real memory address is in "firstaddr".
! 	 * The first available kernel virtual address is in "v".
! 	 * As pages of kernel virtual memory are allocated, "v" is incremented.
! 	 * As pages of memory are allocated and cleared,
! 	 * "firstaddr" is incremented.
! 	 * An index into the kernel page table corresponding to the
! 	 * virtual memory address maintained in "v" is kept in "mapaddr".
! 	 */
! 	/*
! 	 * Make two passes.  The first pass calculates how much memory is
! 	 * needed and allocates it.  The second pass assigns virtual
! 	 * addresses to the various data structures.
! 	 */
! 	firstaddr = 0;
! again:
! 	v = (caddr_t)firstaddr;
! 
! #define	valloc(name, type, num) \
! 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
! #define	valloclim(name, type, num, lim) \
! 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
! /*	valloc(cfree, struct cblock, nclist); */
! 	valloc(callout, struct callout, ncallout);
! #ifdef SYSVSHM
! 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
! #endif
! #ifdef SYSVSEM
! 	valloc(sema, struct semid_ds, seminfo.semmni);
! 	valloc(sem, struct sem, seminfo.semmns);
! 	/* This is pretty disgusting! */
! 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
! #endif
! #ifdef SYSVMSG
! 	valloc(msgpool, char, msginfo.msgmax);
! 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
! 	valloc(msghdrs, struct msg, msginfo.msgtql);
! 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
! #endif
! 	/*
! 	 * If necessary, determine the number of pages to use for the
! 	 * buffer cache.  We allocate 1/2 as many swap buffer headers
! 	 * as file I/O buffers.
! 	 */
!   	if (bufpages == 0) {
! 		if (bufcache == 0) {	/* use old algorithm */
! 			/*
! 			 * Determine how many buffers to allocate. We use 10%
! 			 * of the first 2MB of memory, and 5% of the rest, with
! 			 * a minimum of 16 buffers.
! 			 */
! 			if (physmem < btoc(2 * 1024 * 1024))
! 				bufpages = physmem / (10 * CLSIZE);
! 			else
! 				bufpages = (btoc(2 * 1024 * 1024) + physmem) /
! 				    (20 * CLSIZE);
! 		} else {
! 			/*
! 			 * Set size of buffer cache to physmem/bufcache * 100
! 			 * (i.e., bufcache % of physmem).
! 			 */
! 			if (bufcache < 5 || bufcache > 95) {
! 				printf("warning: unable to set bufcache "
! 				    "to %d%% of RAM, using 10%%", bufcache);
! 				bufcache = 10;
! 			}
! 			bufpages = physmem / (CLSIZE * 100) * bufcache;
! 		}
! 	}
! 	if (nbuf == 0) {
! 		nbuf = bufpages;
! 		if (nbuf < 16)
! 			nbuf = 16;
! 	}
  
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf * 3 / 4) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	/*
- 	 * End of first pass, size has been calculated so allocate memory
- 	 */
- 	if (firstaddr == 0) {
- 		size = (vsize_t)(v - firstaddr);
- 		firstaddr = (caddr_t) uvm_km_zalloc(kernel_map,
- 							round_page(size));
- 		if (firstaddr == 0)
- 			panic("startup: no room for tables");
- 		goto again;
- 	}
  	/*
! 	 * End of second pass, addresses have been assigned
  	 */
! 	if ((vsize_t)(v - firstaddr) != size)
  		panic("startup: table size inconsistency");
  
  	/*
--- 193,209 ----
  	 */
  	printf(version);
  	identifycpu();
  
! 	printf("total memory = %s\n", format_memory(mem_size));
  
  	/*
! 	 * Find out how much space we need, allocate it,
! 	 * and then give everything true virtual addresses.
  	 */
! 	size = (int)allocsys((caddr_t)0);
! 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! 		panic("startup: no room for tables");
! 	if (allocsys(v) - v != size)
  		panic("startup: table size inconsistency");
  
  	/*
*************** again:
*** 410,418 ****
  	pmapdebug = opmapdebug;
  #endif
  	avail_mem = ptoa(uvmexp.free);
! 	printf("avail mem = %ld (%ld pages)\n", avail_mem, avail_mem/NBPG);
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  	
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 300,308 ----
  	pmapdebug = opmapdebug;
  #endif
  	avail_mem = ptoa(uvmexp.free);
! 	printf("avail mem = %s\n", format_memory(avail_mem));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  	
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
Index: arch/bebox/bebox/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/bebox/bebox/machdep.c,v
retrieving revision 1.36
diff -p -c -r1.36 machdep.c
*** machdep.c	1999/04/17 21:16:46	1.36
--- machdep.c	1999/05/08 12:04:20
***************
*** 37,43 ****
  #include "opt_ccitt.h"
  #include "opt_iso.h"
  #include "opt_ns.h"
- #include "opt_sysv.h"
  #include "ipkdb.h"
  
  #include <sys/param.h>
--- 37,42 ----
*************** vaddr_t msgbuf_vaddr;
*** 137,143 ****
  
  paddr_t avail_end;			/* XXX temporary */
  
! caddr_t allocsys __P((caddr_t));
  
  void install_extint __P((void (*)(void)));
  int cold = 1;
--- 136,144 ----
  
  paddr_t avail_end;			/* XXX temporary */
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  void install_extint __P((void (*)(void)));
  int cold = 1;
*************** cpu_startup()
*** 469,476 ****
  	printf("%s", version);
  	identifycpu();
  
! 	printf("real memory  = %d (%dK bytes)\n",
! 		ctob(physmem), ctob(physmem) / 1024);
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 470,476 ----
  	printf("%s", version);
  	identifycpu();
  
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 553,562 ****
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail memory = %d (%dK bytes)\n",
! 		ptoa(uvmexp.free), ptoa(uvmexp.free) / 1024);
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	       nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up the buffers.
--- 553,561 ----
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	   nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up the buffers.
*************** cpu_startup()
*** 573,624 ****
  		asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
  			      : "=r"(msr) : "K"(PSL_EE));
  	}
- }
- 
- /*
-  * Allocate space for system data structures.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- #define	valloc(name, type, num) \
- 	v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef	SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef	SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof (int));
- #endif
- #ifdef	SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Decide on buffer space to use.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = (physmem / 20) / CLSIZE;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) & ~1;
- 		if (nswbuf > 256)
- 			nswbuf = 256;
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	return (v);
  }
  
  /*
--- 572,577 ----
Index: arch/hp300/hp300/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/machdep.c,v
retrieving revision 1.125
diff -p -c -r1.125 machdep.c
*** machdep.c	1999/04/26 22:46:45	1.125
--- machdep.c	1999/05/08 12:04:21
***************
*** 42,52 ****
   *	@(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_compat_hpux.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 42,50 ----
***************
*** 74,88 ****
  #include <sys/core.h>
  #include <sys/kcore.h>
  #include <sys/vnode.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <machine/db_machdep.h>
  #include <ddb/db_sym.h>
--- 72,77 ----
*************** vm_map_t phys_map = NULL;
*** 125,149 ****
  
  extern paddr_t avail_end;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef	BUFCACHE
! int	bufcache = BUFCACHE;
! #else
! int	bufcache = 10;
! #endif
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
  int	physmem = MAXMEM;	/* max supported memory, changes to actual */
--- 114,123 ----
  
  extern paddr_t avail_end;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
! 
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
  int	physmem = MAXMEM;	/* max supported memory, changes to actual */
*************** extern struct emul emul_hpux;
*** 161,167 ****
  #endif
  
  /* prototypes for local functions */
- caddr_t	allocsys __P((caddr_t));
  void	parityenable __P((void));
  int	parityerror __P((struct frame *));
  int	parityerrorfind __P((void));
--- 135,140 ----
*************** cpu_startup()
*** 308,314 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 281,287 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 318,324 ****
  	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
  		panic("startup: no room for tables");
  	if ((allocsys(v) - v) != size)
! 		panic("startup: talbe size inconsistency");
  
  	/*
  	 * Now allocate buffers proper.  They are different than the above
--- 291,297 ----
  	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
  		panic("startup: no room for tables");
  	if ((allocsys(v) - v) != size)
! 		panic("startup: table size inconsistency");
  
  	/*
  	 * Now allocate buffers proper.  They are different than the above
*************** cpu_startup()
*** 394,402 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Tell the VM system that page 0 isn't mapped.
--- 367,375 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Tell the VM system that page 0 isn't mapped.
*************** cpu_startup()
*** 428,500 ****
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and the call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define	valloc(name, type, num)	\
- 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
- #define	valloclim(name, type, num, lim) \
- 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM 
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns); 
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate.  Since HPs tend
- 	 * to be long on memory and short on disk speed, we allocate
- 	 * more buffer space than the BSD standard of 10% of memory
- 	 * for the first 2 Meg, 5% of the remaining.  We just allocate
- 	 * a flag 10%.  Insure a minimum of 16 buffers.  We allocate
- 	 * 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache < 5 || bufcache > 95) {
- 			printf(
- 		"WARNING: unable to set bufcache to %d%% of RAM, using 10%%",
- 			    bufcache);
- 			bufcache = 10;
- 		}
- 		bufpages = physmem * bufcache / (CLSIZE * 100);
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return (v);
  }
  
  /*
--- 401,406 ----
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.352
diff -p -c -r1.352 machdep.c
*** machdep.c	1999/04/26 22:46:45	1.352
--- machdep.c	1999/05/08 12:04:22
***************
*** 75,81 ****
   *	@(#)machdep.c	7.4 (Berkeley) 6/3/91
   */
  
- #include "opt_bufcache.h"
  #include "opt_cputype.h"
  #include "opt_ddb.h"
  #include "opt_vm86.h"
--- 75,80 ----
***************
*** 84,90 ****
  #include "opt_compat_netbsd.h"
  #include "opt_cpureset_delay.h"
  #include "opt_compat_svr4.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 83,88 ----
***************
*** 110,124 ****
  #include <sys/core.h>
  #include <sys/kcore.h>
  #include <machine/kcore.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #ifdef KGDB
  #include <sys/kgdb.h>
--- 108,113 ----
*************** char bootinfo[BOOTINFO_MAXSIZE];
*** 226,251 ****
  struct bi_devmatch *i386_alldisks = NULL;
  int i386_ndisks = 0;
  
- /*
-  * Declare these as initialized data so we can patch them.
-  */
- int	nswbuf = 0;
- #ifdef	NBUF
- int	nbuf = NBUF;
- #else
- int	nbuf = 0;
- #endif
- #ifdef	BUFPAGES
- int	bufpages = BUFPAGES;
- #else
- int	bufpages = 0;
- #endif
- #ifdef BUFCACHE
- int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
- #else
- int	bufcache = 0;		/* fallback to old algorithm */
- #endif
- 
  #ifdef CPURESET_DELAY
  int	cpureset_delay = CPURESET_DELAY;
  #else
--- 215,220 ----
*************** static	int ioport_malloc_safe;
*** 301,307 ****
  phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
  int	mem_cluster_cnt;
  
- caddr_t	allocsys __P((caddr_t));
  int	cpu_dump __P((void));
  int	cpu_dumpsize __P((void));
  u_long	cpu_dump_mempagecnt __P((void));
--- 270,275 ----
*************** int comkgdbmode = KGDBMODE;
*** 357,362 ****
--- 325,334 ----
  void kgdb_port_init __P((void));
  #endif /* KGDB */
  
+ extern caddr_t		 allocsys __P((caddr_t));
+ extern const char	*format_memory __P((int64_t));
+ extern int		 nbuf, nswbuf;
+ 
  #ifdef COMPAT_NOMID
  static int exec_nomid	__P((struct proc *, struct exec_package *));
  #endif
*************** cpu_startup()
*** 403,409 ****
  	 * Initialize error message buffer (et end of core).
  	 */
  #if defined(PMAP_NEW)
! 	msgbuf_vaddr =  uvm_km_valloc(kernel_map, i386_round_page(MSGBUFSIZE));
  	if (msgbuf_vaddr == NULL)
  		panic("failed to valloc msgbuf_vaddr");
  #endif
--- 375,381 ----
  	 * Initialize error message buffer (et end of core).
  	 */
  #if defined(PMAP_NEW)
! 	msgbuf_vaddr = uvm_km_valloc(kernel_map, i386_round_page(MSGBUFSIZE));
  	if (msgbuf_vaddr == NULL)
  		panic("failed to valloc msgbuf_vaddr");
  #endif
*************** cpu_startup()
*** 423,429 ****
  	printf(version);
  	identifycpu();
  
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 395,401 ----
  	printf(version);
  	identifycpu();
  
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 497,505 ****
  	 * XXX we need to account for those pages when printing
  	 * XXX the amount of free memory.
  	 */
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free - bufpages));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  #if NBIOSCALL > 0
  	/*
--- 469,478 ----
  	 * XXX we need to account for those pages when printing
  	 * XXX the amount of free memory.
  	 */
! 	printf("avail memory = %s\n",
! 	    format_memory(ptoa(uvmexp.free - bufpages)));
! 	printf("using %d buffers containing %s of memory\n",
! 		nbuf, format_memory(bufpages * CLBYTES));
  
  #if NBIOSCALL > 0
  	/*
*************** i386_bufinit()
*** 615,707 ****
  	bufinit();
  }
  
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define	valloc(name, type, num) \
- 	    v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * If necessary, determine the number of pages to use for the
- 	 * buffer cache.  We allocate 1/2 as many swap buffer headers
- 	 * as file I/O buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {		/* use old algorithm */
- 			/*
- 			 * Determine how many buffers to allocate. We use 10%
- 			 * of the first 2MB of memory, and 5% of the rest, with
- 			 * a minimum of 16 buffers.
- 			 */
- 			if (physmem < btoc(2 * 1024 * 1024))
- 				bufpages = physmem / (10 * CLSIZE);
- 			else
- 				bufpages = (btoc(2 * 1024 * 1024) + physmem) /
- 				    (20 * CLSIZE);
- 		} else {
- 			/*
- 			 * Set size of buffer cache to physmem/bufcache * 100
- 			 * (i.e., bufcache % of physmem).
- 			 */
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf(
- 		"warning: unable to set bufcache to %d%% of RAM, using 10%%",
- 				    bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages= physmem / (CLSIZE * 100) * bufcache;
- 		}
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	/*
- 	 * XXX stopgap measure to prevent wasting too much KVM on
- 	 * the sparsely filled buffer cache.
- 	 */
- 	if (nbuf * MAXBSIZE > VM_MAX_KERNEL_BUF)
- 		nbuf = VM_MAX_KERNEL_BUF / MAXBSIZE;
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return v;
- }
- 
  /*  
   * Info for CTL_HW
   */
--- 588,593 ----
*************** init386(first_avail)
*** 1821,1828 ****
  	 * is what puts us over 16M.
  	 */
  	if (biosextmem > (15*1024) && biosextmem < (16*1024)) {
! 		printf("Warning: ignoring %dk of remapped memory\n",
! 		    biosextmem - (15*1024));
  		biosextmem = (15*1024);
  	}
  #endif
--- 1707,1714 ----
  	 * is what puts us over 16M.
  	 */
  	if (biosextmem > (15*1024) && biosextmem < (16*1024)) {
! 		printf("Warning: ignoring %s of remapped memory\n",
! 		    format_memory(biosextmem - (15*1024)));
  		biosextmem = (15*1024);
  	}
  #endif
Index: arch/mac68k/mac68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.232
diff -p -c -r1.232 machdep.c
*** machdep.c	1999/05/03 19:10:54	1.232
--- machdep.c	1999/05/08 12:04:25
***************
*** 77,86 ****
   */
  
  #include "opt_adb.h"
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  #include "zsc.h"
  
  #include <sys/param.h>
--- 77,84 ----
***************
*** 108,122 ****
  #ifdef	KGDB
  #include <sys/kgdb.h>
  #endif
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <machine/db_machdep.h>
  #include <ddb/db_sym.h>
--- 106,111 ----
*************** vm_map_t exec_map = NULL;  
*** 190,214 ****
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef BUFCACHE
! int	bufcache = BUFCACHE;
! #else
! int	bufcache = 0;
! #endif
  
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
--- 179,187 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
*************** cpu_startup(void)
*** 403,507 ****
  		printf("this kernel.\n\n");
  		for (delay = 0; delay < 1000000; delay++);
  	}
! 	printf("real mem = %d\n", ctob(physmem));
  
- 	/*
- 	 * Allocate space for system data structures.
- 	 * The first available real memory address is in "firstaddr".
- 	 * The first available kernel virtual address is in "v".
- 	 * As pages of kernel virtual memory are allocated, "v" is incremented.
- 	 * As pages of memory are allocated and cleared,
- 	 * "firstaddr" is incremented.
- 	 * An index into the kernel page table corresponding to the
- 	 * virtual memory address maintained in "v" is kept in "mapaddr".
- 	 */
- 	/*
- 	 * Make two passes.  The first pass calculates how much memory is
- 	 * needed and allocates it.  The second pass assigns virtual
- 	 * addresses to the various data structures.
- 	 */
- 	firstaddr = 0;
- again:
- 	v = (caddr_t)firstaddr;
- 
- #define	valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
- #define	valloclim(name, type, num, lim) \
- 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 	/*
- 	 * Determine the number of pages to use for the buffer cache
- 	 * (minimum 16).  Allocate 3/4 as many swap buffer headers as
- 	 * file I/O buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {	/* use old algorithm */
- 			/*
- 			 * Determine how many buffers to allocate. We use 10%
- 			 * of the first 2MB of memory, and 5% of the rest.
- 			 */
- 			if (physmem < btoc(2 * 1024 * 1024))
- 				bufpages = physmem / (10 * CLSIZE);
- 			else
- 				bufpages = (btoc(2 * 1024 * 1024) + physmem) /
- 				    (20 * CLSIZE);
- 		} else {
- 			/*
- 			 * Set size of buffer cache to physmem/bufcache * 100
- 			 * (i.e., bufcache % of physmem).
- 			 */
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf("warning: unable to set bufcache "
- 				    "to %d%% of RAM, using 10%%", bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages = physmem / (CLSIZE * 100) * bufcache;
- 		}
- 	}
- 
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf * 3 / 4) & ~1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;	/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	/*
- 	 * End of first pass, size has been calculated so allocate memory
- 	 */
- 	if (firstaddr == 0) {
- 		size = (vsize_t)(v - firstaddr);
- 		firstaddr = (caddr_t)uvm_km_alloc(kernel_map, round_page(size));
- 		if (firstaddr == 0)
- 			panic("startup: no room for tables");
- 		goto again;
- 	}
  	/*
! 	 * End of second pass, addresses have been assigned
  	 */
! 	if ((vsize_t)(v - firstaddr) != size)
  		panic("startup: table size inconsistency");
  
  	/*
--- 376,391 ----
  		printf("this kernel.\n\n");
  		for (delay = 0; delay < 1000000; delay++);
  	}
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
! 	 * Find out how much space we need, allocate it,
! 	 * and then give everything true virtual addresses.
  	 */
! 	size = (vm_size_t)allocsys((caddr_t)0);
! 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! 		panic("startup: no room for tables");
! 	if (allocsys(v) - v != size)
  		panic("startup: table size inconsistency");
  
  	/*
*************** again:
*** 568,576 ****
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	    nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up CPU-specific registers, cache, etc.
--- 452,460 ----
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail mem = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up CPU-specific registers, cache, etc.
Index: arch/macppc/macppc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/macppc/machdep.c,v
retrieving revision 1.44
diff -p -c -r1.44 machdep.c
*** machdep.c	1999/05/07 22:20:38	1.44
--- machdep.c	1999/05/08 12:04:25
***************
*** 31,37 ****
   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
- #include "opt_bufcache.h"
  #include "opt_compat_netbsd.h"
  #include "opt_ddb.h"
  #include "opt_inet.h"
--- 31,36 ----
***************
*** 40,46 ****
  #include "opt_iso.h"
  #include "opt_ns.h"
  #include "opt_natm.h"
- #include "opt_sysv.h"
  #include "adb.h"
  #include "ipkdb.h"
  
--- 39,44 ----
***************
*** 59,73 ****
  #include <sys/syslog.h>
  #include <sys/systm.h>
  #include <sys/user.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <vm/vm.h>
  #include <vm/vm_kern.h>
--- 57,62 ----
*************** struct pmap ofw_pmap;
*** 131,156 ****
  
  int msgbufmapped = 0;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef BUFCACHE
! int	bufcache = BUFCACHE;
! #else
! int	bufcache = 0;
! #endif
  
- caddr_t allocsys __P((caddr_t));
  void install_extint __P((void (*)(void)));
  
  int cold = 1;
--- 120,129 ----
  
  int msgbufmapped = 0;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  void install_extint __P((void (*)(void)));
  
  int cold = 1;
*************** cpu_startup()
*** 511,517 ****
  	printf("%s", version);
  	identifycpu();
  
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 484,490 ----
  	printf("%s", version);
  	identifycpu();
  
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 589,665 ****
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	       nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up the buffers.
  	 */
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- #define	valloc(name, type, num) \
- 	v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef	SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef	SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef	SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine the number of pages to use for the buffer cache
- 	 * (minimum 16).  Allocate 1/2 as many swap buffer headers as
- 	 * file I/O buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {	/* use old algorithm */
- 			bufpages = (physmem / 20) / CLSIZE;
- 		} else {
- 			/*
- 			 * Set size of buffer cache to physmem/bufcache * 100
- 			 * (i.e., bufcache % of physmem).
- 			 */
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf("warning: unable to set bufcache "
- 				    "to %d%% of RAM, using 10%%", bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages = physmem / (CLSIZE * 100) * bufcache;
- 		}
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) & ~1;
- 		if (nswbuf > 256)
- 			nswbuf = 256;
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	return v;
- #undef valloc
  }
  
  /*
--- 562,575 ----
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    format_memory(nbuf, bufpages * CLBYTES));
  
  	/*
  	 * Set up the buffers.
  	 */
  	bufinit();
  }
  
  /*
Index: arch/mips/include/cpu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/cpu.h,v
retrieving revision 1.29
diff -p -c -r1.29 cpu.h
*** cpu.h	1999/03/23 22:04:01	1.29
--- cpu.h	1999/05/08 12:04:26
*************** void	child_return __P((void *));
*** 180,186 ****
  int	kdbpeek __P((vaddr_t));
  
  /* mips_machdep.c */
- caddr_t	allocsys __P((caddr_t));
  void	dumpsys __P((void));
  int	savectx __P((struct user *));
  void	mips_init_msgbuf __P((void));
--- 180,185 ----
Index: arch/mips/mips/mips_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/mips_machdep.c,v
retrieving revision 1.51
diff -p -c -r1.51 mips_machdep.c
*** mips_machdep.c	1999/04/25 02:56:28	1.51
--- mips_machdep.c	1999/05/08 12:04:26
***************
*** 54,63 ****
  
  __KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.51 1999/04/25 02:56:28 simonb Exp $");
  
- #include "opt_bufcache.h"
  #include "opt_compat_netbsd.h"
  #include "opt_compat_ultrix.h"
- #include "opt_sysv.h"
  #include "opt_cputype.h"
  
  #include <sys/param.h>
--- 54,61 ----
*************** __KERNEL_RCSID(0, "$NetBSD: mips_machdep
*** 78,92 ****
  #include <sys/core.h>
  #include <sys/kcore.h>
  #include <machine/kcore.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <vm/vm.h>
  
--- 76,81 ----
*************** mips_locore_jumpvec_t mips_locore_jumpve
*** 118,141 ****
    NULL, NULL
  };
  
- /*
-  * Declare these as initialized data so we can patch them.
-  */
- #ifndef NBUF
- #define NBUF		0
- #endif
- #ifndef BUFPAGES
- #define BUFPAGES	0
- #endif
- #ifndef BUFCACHE
- #define BUFCACHE	10
- #endif
- 
- int	nswbuf = 0;
- int	nbuf = NBUF;
- int	bufpages = BUFPAGES;	/* optional hardwired count */
- int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
- 
  int cpu_mhz;
  int mips_num_tlb_entries;
  
--- 107,112 ----
*************** dumpsys()
*** 1129,1192 ****
  	}
  	printf("\n\n");
  	delay(5000000);		/* 5 seconds */
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way, we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and the call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)ALIGN((name)+(num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate.
- 	 * We allocate bufcache % of memory for buffer space.  Ensure a
- 	 * minimum of 16 buffers.  We allocate 1/2 as many swap buffer
- 	 * headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = physmem / CLSIZE * bufcache / 100;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	return (v);
- #undef valloc
  }
  
  void
--- 1100,1105 ----
Index: arch/mvme68k/mvme68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/machdep.c,v
retrieving revision 1.55
diff -p -c -r1.55 machdep.c
*** machdep.c	1999/04/26 22:46:47	1.55
--- machdep.c	1999/05/08 12:04:27
***************
*** 42,51 ****
   *	@(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_compat_hpux.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 42,49 ----
***************
*** 71,85 ****
  #include <sys/kcore.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <vm/vm.h>
  #include <vm/vm_kern.h>
--- 69,74 ----
*************** vm_map_t phys_map = NULL;
*** 115,134 ****
   */
  struct	mvmeprom_brdid  boardid;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  caddr_t	msgbufaddr;		/* KVA of message buffer */
  paddr_t msgbufpa;		/* PA of message buffer */
  
--- 104,113 ----
   */
  struct	mvmeprom_brdid  boardid;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
! 
  caddr_t	msgbufaddr;		/* KVA of message buffer */
  paddr_t msgbufpa;		/* PA of message buffer */
  
*************** extern struct emul emul_hpux;
*** 151,157 ****
  #endif
  
  /* prototypes for local functions */ 
- caddr_t	allocsys __P((caddr_t));
  void	identifycpu __P((void));
  void	initcpu __P((void));
  void	dumpsys __P((void));
--- 130,135 ----
*************** cpu_startup()
*** 398,404 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real mem  = %d", ctob(physmem));
  	
  	for (vmememsize = 0, i = 1; i < mem_cluster_cnt; i++)
  		vmememsize += mem_clusters[i].size;
--- 376,382 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s", format_memory(ctob(physmem)));
  	
  	for (vmememsize = 0, i = 1; i < mem_cluster_cnt; i++)
  		vmememsize += mem_clusters[i].size;
*************** cpu_startup()
*** 492,500 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Tell the VM system that the area before the text segment
--- 470,478 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Tell the VM system that the area before the text segment
*************** cpu_startup()
*** 525,587 ****
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way, we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and the call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
- #define valloclim(name, type, num, lim) \
- 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate.
- 	 * We just allocate a flat 5%.  Insure a minimum of 16 buffers.
- 	 * We allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = physmem / 20 / CLSIZE;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return (v);
  }
  
  /*
--- 503,508 ----
Index: arch/newsmips/newsmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/machdep.c,v
retrieving revision 1.25
diff -p -c -r1.25 machdep.c
*** machdep.c	1999/04/11 04:04:08	1.25
--- machdep.c	1999/05/08 12:04:29
*************** vm_map_t exec_map = NULL;
*** 109,114 ****
--- 109,118 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
+ extern caddr_t		 allocsys __P((caddr_t));
+ extern const char	*format_memory __P((int64_t));
+ extern int		 nbuf, nswbuf;
+ 
  int maxmem;			/* max memory per process */
  int physmem;			/* max supported memory, changes to actual */
  
*************** cpu_startup()
*** 341,347 ****
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf(version);
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
--- 345,351 ----
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf(version);
! 	printf("total mem = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
*************** cpu_startup()
*** 416,424 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 420,428 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
Index: arch/next68k/next68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/next68k/next68k/machdep.c,v
retrieving revision 1.22
diff -p -c -r1.22 machdep.c
*** machdep.c	1999/04/26 22:46:47	1.22
--- machdep.c	1999/05/08 12:04:29
***************
*** 43,52 ****
   *	@(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_compat_hpux.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 43,50 ----
***************
*** 73,87 ****
  #include <sys/kcore.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  #ifdef KGDB
  #include <sys/kgdb.h>
  #endif
--- 71,76 ----
*************** vm_map_t exec_map = NULL;
*** 134,153 ****
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  caddr_t	msgbufaddr;		/* KVA of message buffer */
  paddr_t msgbufpa;		/* PA of message buffer */
  
--- 123,132 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
! 
  caddr_t	msgbufaddr;		/* KVA of message buffer */
  paddr_t msgbufpa;		/* PA of message buffer */
  
*************** extern struct emul emul_hpux;
*** 168,174 ****
  #endif
  
  /* prototypes for local functions */
- caddr_t	allocsys __P((caddr_t));
  void	identifycpu __P((void));
  void	initcpu __P((void));
  void	dumpsys __P((void));
--- 147,152 ----
*************** cpu_startup()
*** 346,354 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real mem  = %d", ctob(physmem));
! 	
! 	printf("\n");
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 324,330 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 434,442 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Tell the VM system that the area before the text segment
--- 410,418 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Tell the VM system that the area before the text segment
*************** cpu_startup()
*** 467,529 ****
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way, we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and the call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
- #define valloclim(name, type, num, lim) \
- 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate.
- 	 * We just allocate a flat 5%.  Insure a minimum of 16 buffers.
- 	 * We allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = physmem / 20 / CLSIZE;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return (v);
  }
  
  /*
--- 443,448 ----
Index: arch/ofppc/ofppc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/ofppc/ofppc/machdep.c,v
retrieving revision 1.39
diff -p -c -r1.39 machdep.c
*** machdep.c	1999/05/05 00:03:10	1.39
--- machdep.c	1999/05/08 12:04:29
***************
*** 37,43 ****
  #include "opt_ccitt.h"
  #include "opt_iso.h"
  #include "opt_ns.h"
- #include "opt_sysv.h"
  #include "ipkdb.h"
  
  #include <sys/param.h>
--- 37,42 ----
*************** char *bootpath;
*** 90,96 ****
  paddr_t msgbuf_paddr;
  vaddr_t msgbuf_vaddr;
  
! caddr_t allocsys __P((caddr_t));
  
  static int fake_spl __P((void));
  static int fake_splx __P((int));
--- 89,97 ----
  paddr_t msgbuf_paddr;
  vaddr_t msgbuf_vaddr;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  static int fake_spl __P((void));
  static int fake_splx __P((int));
*************** cpu_startup()
*** 391,397 ****
  	printf("%s", version);
  	identifycpu();
  
! 	printf("real mem = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 392,398 ----
  	printf("%s", version);
  	identifycpu();
  
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 474,482 ****
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail memory = %d\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 	       nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up the buffers.
--- 475,483 ----
  	for (i = 1; i < ncallout; i++)
  		callout[i - 1].c_next = &callout[i];
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	   nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up the buffers.
*************** cpu_startup()
*** 502,553 ****
  		asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
  			      : "=r"(msr) : "K"((u_short)(PSL_EE|PSL_RI)));
  	}
- }
- 
- /*
-  * Allocate space for system data structures.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- #define	valloc(name, type, num) \
- 	v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef	SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef	SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof (int));
- #endif
- #ifdef	SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Decide on buffer space to use.
- 	 */
- 	if (bufpages == 0)
- 		bufpages = (physmem / 20) / CLSIZE;
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) & ~1;
- 		if (nswbuf > 256)
- 			nswbuf = 256;
- 	}
- 	valloc(buf, struct buf, nbuf);
- 
- 	return (v);
  }
  
  /*
--- 503,508 ----
Index: arch/pc532/pc532/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pc532/pc532/machdep.c,v
retrieving revision 1.99
diff -p -c -r1.99 machdep.c
*** machdep.c	1999/04/26 22:46:47	1.99
--- machdep.c	1999/05/08 12:04:29
***************
*** 42,48 ****
   *	@(#)machdep.c	7.4 (Berkeley) 6/3/91
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_inet.h"
  #include "opt_atalk.h"
--- 42,47 ----
***************
*** 52,58 ****
  #include "opt_natm.h"
  #include "opt_pmap_new.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 51,56 ----
***************
*** 76,90 ****
  #include <sys/syscallargs.h>
  #include <sys/core.h>
  #include <sys/kcore.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <dev/cons.h>
  
--- 74,79 ----
*************** char	cpu_model[] = "ns32532";
*** 163,187 ****
  
  struct user *proc0paddr;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef BUFCACHE
! int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
! #else
! int	bufcache = 0;		/* fallback to old algorithm */
! #endif
  
  int	maxphysmem = 0;
  int	physmem;
--- 152,160 ----
  
  struct user *proc0paddr;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  int	maxphysmem = 0;
  int	physmem;
*************** extern	int nkpde;
*** 203,209 ****
  extern	int ieee_handler_disable;
  
  static paddr_t	alloc_pages __P((int));
- static caddr_t 	allocsys __P((caddr_t));
  static int	cpu_dump __P((void));
  static int	cpu_dumpsize __P((void));
  static void	cpu_reset __P((void));
--- 176,181 ----
*************** cpu_startup()
*** 247,253 ****
  	initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE));
  
  	printf(version);
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 219,225 ----
  	initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE));
  
  	printf(version);
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 343,443 ****
  	for (i = 1; i < ncallout; i++)
  		callout[i-1].c_next = &callout[i];
  
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- static caddr_t
- allocsys(v)
- 	register caddr_t v;
- {
- 
- #define	valloc(name, type, num) \
- 	    v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * If necessary, determine the number of pages to use for the
- 	 * buffer cache.  We allocate 1/2 as many swap buffer headers
- 	 * as file I/O buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {		/* use old algorithm */
- 			/*
- 			 * Determine how many buffers to allocate. We use 10%
- 			 * of the first 2MB of memory, and 5% of the rest, with
- 			 * a minimum of 16 buffers.
- 			 */
- 			if (physmem < btoc(2 * 1024 * 1024))
- 				bufpages = physmem / (10 * CLSIZE);
- 			else
- 				bufpages = (btoc(2 * 1024 * 1024) + physmem) /
- 				    (20 * CLSIZE);
- 		} else {
- 			/*
- 			 * Set size of buffer cache to physmem/bufcache * 100
- 			 * (i.e., bufcache % of physmem).
- 			 */
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf(
- 		"warning: unable to set bufcache to %d%% of RAM, using 10%%",
- 				    bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages= physmem / (CLSIZE * 100) * bufcache;
- 		}
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	/*
- 	 * XXX stopgap measure to prevent wasting too much KVM on
- 	 * the sparsely filled buffer cache.
- 	 */
- 	if (nbuf * MAXBSIZE > VM_MAX_KERNEL_BUF)
- 		nbuf = VM_MAX_KERNEL_BUF / MAXBSIZE;
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return v;
  }
  
  /*
--- 315,328 ----
  	for (i = 1; i < ncallout; i++)
  		callout[i-1].c_next = &callout[i];
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  	bufinit();
  }
  
  /*
Index: arch/pica/pica/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pica/pica/machdep.c,v
retrieving revision 1.22
diff -p -c -r1.22 machdep.c
*** machdep.c	1999/04/01 00:17:48	1.22
--- machdep.c	1999/05/08 12:04:30
*************** char	cpu_model[30];
*** 106,111 ****
--- 106,115 ----
  
  vm_map_t buffer_map;
  
+ extern caddr_t		 allocsys __P((caddr_t));
+ extern const char	*format_memory __P((int64_t));
+ extern int		 nbuf, nswbuf;
+ 
  int	maxmem;			/* max memory per process */
  int	physmem;		/* max supported memory, changes to actual */
  int	memcfg;			/* memory config register */
*************** cpu_startup()
*** 491,497 ****
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf(version);
! 	printf("real mem = %d\n", ctob(physmem));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
--- 495,501 ----
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf(version);
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
*************** cpu_startup()
*** 551,559 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(cnt.v_free_count));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  	/*
  	 * Set up CPU-specific registers, cache, etc.
  	 */
--- 555,564 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(cnt.v_free_count)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
! 
  	/*
  	 * Set up CPU-specific registers, cache, etc.
  	 */
Index: arch/pmax/pmax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/pmax/machdep.c,v
retrieving revision 1.140
diff -p -c -r1.140 machdep.c
*** machdep.c	1999/05/07 18:04:36	1.140
--- machdep.c	1999/05/08 12:04:31
*************** vm_map_t exec_map = NULL;
*** 140,145 ****
--- 140,149 ----
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
+ extern caddr_t		 allocsys __P((caddr_t));
+ extern const char	*format_memory __P((int64_t));
+ extern int		 nbuf, nswbuf;
+ 
  char	*bootinfo = NULL;	/* pointer to bootinfo structure */
  int	systype;		/* Mother board type */
  int	maxmem;			/* max memory per process */
*************** cpu_startup()
*** 502,508 ****
  	 */
  	printf(version);
  	printf("%s\n", cpu_model);
! 	printf("real mem  = %d\n", ctob(physmem));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
--- 506,512 ----
  	 */
  	printf(version);
  	printf("%s\n", cpu_model);
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Allocate virtual address space for file I/O buffers.
*************** cpu_startup()
*** 584,592 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 588,596 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
Index: arch/sparc/sparc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/machdep.c,v
retrieving revision 1.146
diff -p -c -r1.146 machdep.c
*** machdep.c	1999/05/03 16:17:57	1.146
--- machdep.c	1999/05/08 12:04:32
***************
*** 81,90 ****
   *	@(#)machdep.c	8.6 (Berkeley) 1/14/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_compat_netbsd.h"
  #include "opt_compat_sunos.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/signal.h>
--- 81,88 ----
***************
*** 107,121 ****
  #include <sys/msgbuf.h>
  #include <sys/syscallargs.h>
  #include <sys/exec.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <vm/vm.h>
  #include <vm/vm_kern.h>
--- 105,110 ----
*************** vm_map_t exec_map = NULL;
*** 150,169 ****
  vm_map_t mb_map = NULL;
  extern paddr_t avail_end;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  
  int	physmem;
  
--- 139,147 ----
  vm_map_t mb_map = NULL;
  extern paddr_t avail_end;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  int	physmem;
  
*************** int   safepri = 0;
*** 179,185 ****
   */
  struct extent *dvmamap24;
  
- caddr_t allocsys __P((caddr_t));
  void	dumpsys __P((void));
  void	stackdump __P((void));
  
--- 157,162 ----
*************** cpu_startup()
*** 223,229 ****
  	 */
  	printf(version);
  	/*identifycpu();*/
! 	printf("real mem = %d\n", ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 200,206 ----
  	 */
  	printf(version);
  	/*identifycpu();*/
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 320,328 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 297,305 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
*************** cpu_startup()
*** 330,402 ****
  	bufinit();
  
  	pmap_redzone();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * You call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	caddr_t v;
- {
- 
- #define	valloc(name, type, num) \
- 	    v = (caddr_t)(((name) = (type *)v) + (num))
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate (enough to
- 	 * hold 5% of total physical memory, but at least 16 and at
- 	 * most 1/2 of available kernel virtual memory).
- 	 * Allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		int bmax = btoc(VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
- 			   (MAXBSIZE/NBPG) / 2;
- 		bufpages = (physmem / 20) / CLSIZE;
- 		if (nbuf == 0 && bufpages > bmax)
- 			bufpages = bmax;
- 		/*
- 		 * XXX stopgap measure to prevent wasting too much KVM on
- 		 * the sparsely filled buffer cache.
- 		 */
- 		if (CPU_ISSUN4C && bufpages > (128 * (65536/MAXBSIZE)))
- 			bufpages = (128 * (65536/MAXBSIZE));
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return (v);
  }
  
  /*
--- 307,312 ----
Index: arch/sparc64/sparc64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/machdep.c,v
retrieving revision 1.38
diff -p -c -r1.38 machdep.c
*** machdep.c	1999/04/26 22:46:48	1.38
--- machdep.c	1999/05/08 12:04:33
***************
*** 81,90 ****
   *	@(#)machdep.c	8.6 (Berkeley) 1/14/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_compat_sunos.h"
  #include "opt_compat_netbsd.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/signal.h>
--- 81,88 ----
***************
*** 106,120 ****
  #include <sys/msgbuf.h>
  #include <sys/syscallargs.h>
  #include <sys/exec.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <vm/vm.h>
  #include <vm/vm_kern.h>
--- 104,109 ----
*************** vm_map_t mb_map = NULL;
*** 144,163 ****
  vm_map_t phys_map = NULL;
  extern vaddr_t avail_end;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  
  int	physmem;
  
--- 133,141 ----
  vm_map_t phys_map = NULL;
  extern vaddr_t avail_end;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  int	physmem;
  
*************** vaddr_t dvma_base, dvma_end;
*** 177,183 ****
  struct map *dvmamap;
  static int ndvmamap;	/* # of entries in dvmamap */
  
- caddr_t allocsys __P((caddr_t));
  void	dumpsys __P((void));
  void	stackdump __P((void));
  
--- 155,160 ----
*************** cpu_startup()
*** 210,216 ****
  	 */
  	printf(version);
  	/*identifycpu();*/
! 	printf("real mem = %ld\n", (long)ctob(physmem));
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 187,193 ----
  	 */
  	printf(version);
  	/*identifycpu();*/
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 313,321 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %ld buffers containing %ld bytes of memory\n",
! 		(long)nbuf, (long)bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
--- 290,298 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
*************** cpu_startup()
*** 325,396 ****
  #if 0
  	pmap_redzone();
  #endif
- }
- 
- /*
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * You call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	register caddr_t v;
- {
- 
- #define	valloc(name, type, num) \
- 	    v = (caddr_t)(((name) = (type *)v) + (num))
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate (enough to
- 	 * hold 5% of total physical memory, but at least 16 and at
- 	 * most 1/2 of available kernel virtual memory).
- 	 * Allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		int bmax = btoc(VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
- 			   (MAXBSIZE/NBPG) / 2;
- 		bufpages = (physmem / 20) / CLSIZE;
- 		if (nbuf == 0 && bufpages > bmax)
- 			bufpages = bmax;
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	/*
- 	 * Allocate DVMA slots for 1/4 of the number of i/o buffers
- 	 * and one for each process too (PHYSIO).
- 	 */
- 	valloc(dvmamap, struct map, ndvmamap = maxproc + ((nbuf / 4) &~ 1));
- 	return (v);
  }
  
  /*
--- 302,307 ----
Index: arch/sun3/sun3/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3/machdep.c,v
retrieving revision 1.129
diff -p -c -r1.129 machdep.c
*** machdep.c	1999/04/26 22:46:48	1.129
--- machdep.c	1999/05/08 12:04:33
***************
*** 43,51 ****
   *	from: @(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 43,49 ----
***************
*** 71,85 ****
  #include <sys/kcore.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  #ifdef	KGDB
  #include <sys/kgdb.h>
  #endif
--- 69,74 ----
*************** vm_offset_t vmmap;
*** 133,152 ****
   */
  int	safepri = PSL_LOWIPL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  
  /* Our private scratch page for dumping the MMU. */
  static vm_offset_t dumppage;
--- 122,130 ----
   */
  int	safepri = PSL_LOWIPL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  /* Our private scratch page for dumping the MMU. */
  static vm_offset_t dumppage;
*************** consinit()
*** 197,265 ****
  }
  
  /*
-  * allocsys() - Private routine used by cpu_startup() below.
-  *
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- #define	valloc(name, type, num) \
- 	v = (caddr_t)(((name) = (type *)v) + (num))
- static caddr_t allocsys __P((caddr_t));
- 
- static caddr_t
- allocsys(v)
- 	register caddr_t v;
- {
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate. We allocate
- 	 * the BSD standard of use 10% of memory for the first 2 Meg,
- 	 * 5% of remaining. Insure a minimum of 16 buffers.
- 	 * Allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		/* We always have more than 2MB of memory. */
- 		bufpages = ((btoc(2 * 1024 * 1024) + physmem) /
- 		            (20 * CLSIZE));
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return v;
- }
- #undef	valloc
- 
- /*
   * cpu_startup: allocate memory for variable-sized tables,
   * initialize cpu, and do autoconfiguration.
   *
--- 175,180 ----
*************** cpu_startup()
*** 294,301 ****
  	identifycpu();
  	initfpu();	/* also prints FPU type */
  
! 	size = ptoa(physmem);
! 	printf("real  mem = %ldK (0x%lx)\n", (size >> 10), size);
  
  	/*
  	 * Get scratch page for dumpsys().
--- 209,215 ----
  	identifycpu();
  	initfpu();	/* also prints FPU type */
  
! 	printf("total memory = %s\n", format_memory(ptoa(physmem)));
  
  	/*
  	 * Get scratch page for dumpsys().
*************** cpu_startup()
*** 389,398 ****
  		callout[i-1].c_next = &callout[i];
  	callout[i-1].c_next = NULL;
  
! 	size = ptoa(uvmexp.free);
! 	printf("avail mem = %ldK (0x%lx)\n", (size >> 10), size);
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		   nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Tell the VM system that writing to kernel text isn't allowed.
--- 303,311 ----
  		callout[i-1].c_next = &callout[i];
  	callout[i-1].c_next = NULL;
  
! 	printf("avail mem = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Tell the VM system that writing to kernel text isn't allowed.
Index: arch/sun3/sun3x/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3x/machdep.c,v
retrieving revision 1.49
diff -p -c -r1.49 machdep.c
*** machdep.c	1999/04/26 22:46:48	1.49
--- machdep.c	1999/05/08 12:04:34
***************
*** 41,49 ****
   *	from: @(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 41,47 ----
***************
*** 69,83 ****
  #include <sys/kcore.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  #ifdef	KGDB
  #include <sys/kgdb.h>
  #endif
--- 67,72 ----
*************** vm_offset_t vmmap;
*** 131,150 ****
   */
  int	safepri = PSL_LOWIPL;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
  
  u_char cpu_machine_id = 0;
  char *cpu_string = NULL;
--- 120,128 ----
   */
  int	safepri = PSL_LOWIPL;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  u_char cpu_machine_id = 0;
  char *cpu_string = NULL;
*************** consinit()
*** 198,266 ****
  }
  
  /*
-  * allocsys() - Private routine used by cpu_startup() below.
-  *
-  * Allocate space for system data structures.  We are given
-  * a starting virtual address and we return a final virtual
-  * address; along the way we set each data structure pointer.
-  *
-  * We call allocsys() with 0 to find out how much space we want,
-  * allocate that much and fill it with zeroes, and then call
-  * allocsys() again with the correct base virtual address.
-  */
- #define	valloc(name, type, num) \
- 	v = (caddr_t)(((name) = (type *)v) + (num))
- static caddr_t allocsys __P((caddr_t));
- 
- static caddr_t
- allocsys(v)
- 	register caddr_t v;
- {
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate. We allocate
- 	 * the BSD standard of use 10% of memory for the first 2 Meg,
- 	 * 5% of remaining. Insure a minimum of 16 buffers.
- 	 * Allocate 1/2 as many swap buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		/* We always have more than 2MB of memory. */
- 		bufpages = ((btoc(2 * 1024 * 1024) + physmem) /
- 		            (20 * CLSIZE));
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return v;
- }
- #undef	valloc
- 
- /*
   * cpu_startup: allocate memory for variable-sized tables,
   * initialize cpu, and do autoconfiguration.
   *
--- 176,181 ----
*************** cpu_startup()
*** 295,302 ****
  	identifycpu();
  	initfpu();	/* also prints FPU type */
  
! 	size = ptoa(physmem);
! 	printf("real  mem = %ldK (0x%lx)\n", (size >> 10), size);
  
  	/*
  	 * Find out how much space we need, allocate it,
--- 210,216 ----
  	identifycpu();
  	initfpu();	/* also prints FPU type */
  
! 	printf("total memory = %s\n", format_memory(ptoa(physmem)));
  
  	/*
  	 * Find out how much space we need, allocate it,
*************** cpu_startup()
*** 384,393 ****
  		callout[i-1].c_next = &callout[i];
  	callout[i-1].c_next = NULL;
  
! 	size = ptoa(uvmexp.free);
! 	printf("avail mem = %ldK (0x%lx)\n", (size >> 10), size);
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		   nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Tell the VM system that writing to kernel text isn't allowed.
--- 298,306 ----
  		callout[i-1].c_next = &callout[i];
  	callout[i-1].c_next = NULL;
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Tell the VM system that writing to kernel text isn't allowed.
Index: arch/vax/vax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/machdep.c,v
retrieving revision 1.82
diff -p -c -r1.82 machdep.c
*** machdep.c	1999/05/02 17:28:43	1.82
--- machdep.c	1999/05/08 12:04:35
***************
*** 45,58 ****
   * @(#)machdep.c	7.16 (Berkeley) 6/3/91
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_inet.h"
  #include "opt_atalk.h"
  #include "opt_ns.h"
  #include "opt_compat_netbsd.h"
  #include "opt_compat_ultrix.h"
- #include "opt_sysv.h"
  
  #include <sys/param.h>
  #include <sys/systm.h>
--- 45,56 ----
***************
*** 75,89 ****
  #include <sys/ptrace.h>
  #include <vm/vm.h>
  #include <sys/sysctl.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <dev/cons.h>
  
--- 73,78 ----
*************** int		dumpsize = 0;
*** 148,174 ****
  #define	IOMAPSZ	100
  static	struct map iomap[IOMAPSZ];
  
! caddr_t allocsys __P((caddr_t));
! 
! #define valloclim(name, type, num, lim) \
! 		(name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
! 
! #ifdef BUFCACHE
! int		bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
! #else 
! int		bufcache = 0;		/* fallback to old algorithm */
! #endif  
! #ifdef	BUFPAGES
! int		bufpages = BUFPAGES;
! #else
! int		bufpages = 0;
! #endif
! int		nswbuf = 0;
! #ifdef	NBUF
! int		nbuf = NBUF;
! #else
! int		nbuf = 0;
! #endif
  
  vm_map_t exec_map = NULL;
  vm_map_t mb_map = NULL;
--- 137,145 ----
  #define	IOMAPSZ	100
  static	struct map iomap[IOMAPSZ];
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  vm_map_t exec_map = NULL;
  vm_map_t mb_map = NULL;
*************** cpu_startup()
*** 202,208 ****
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf("%s\n%s\n", version, cpu_model);
! 	printf("realmem = %d\n", avail_end);
  	physmem = btoc(avail_end);
  	panicstr = NULL;
  	mtpr(AST_NO, PR_ASTLVL);
--- 173,179 ----
  	 * Good {morning,afternoon,evening,night}.
  	 */
  	printf("%s\n%s\n", version, cpu_model);
! 	printf("total memory = %s\n", format_memory(avail_end));
  	physmem = btoc(avail_end);
  	panicstr = NULL;
  	mtpr(AST_NO, PR_ASTLVL);
*************** cpu_startup()
*** 291,374 ****
  		callout[i - 1].c_next = &callout[i];
  	callout[i - 1].c_next = NULL;
  
! 	printf("avail mem = %d\n", (int)ptoa(uvmexp.free));
! 	printf("Using %d buffers containing %d bytes of memory.\n",
! 	       nbuf, bufpages * CLBYTES);
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  
  	bufinit();
- }
- 
- /*
-  * Allocate space for system data structures.  We are given a starting
-  * virtual address and we return a final virtual address; along the way we
-  * set each data structure pointer.
-  * 
-  * We call allocsys() with 0 to find out how much space we want, allocate that
-  * much and fill it with zeroes, and then call allocsys() again with the
-  * correct base virtual address.
-  */
- caddr_t
- allocsys(v)
- 	register caddr_t v;
- {
- 
- #define valloc(name, type, num) \
- 	    v = (caddr_t)(((name) = (type *)v) + (num))
- 
- 	valloc(callout, struct callout, ncallout);
- #ifdef SYSVSHM
- 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
- #endif
- #ifdef SYSVSEM
- 	valloc(sema, struct semid_ds, seminfo.semmni);
- 	valloc(sem, struct sem, seminfo.semmns);
- 	/* This is pretty disgusting! */
- 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
- #endif
- #ifdef SYSVMSG
- 	valloc(msgpool, char, msginfo.msgmax);
- 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
- 	valloc(msghdrs, struct msg, msginfo.msgtql);
- 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
- #endif
- 
- 	/*
- 	 * Determine how many buffers to allocate (enough to hold 5% of total
- 	 * physical memory, but at least 16). Allocate 1/2 as many swap
- 	 * buffer headers as file i/o buffers.
- 	 */
- 	if (bufpages == 0) {
- 		if (bufcache == 0) {
- 			if (physmem < btoc(2 * 1024 * 1024))
- 				bufpages = physmem / 10;
- 			else
- 				bufpages = physmem / 20;
- 		} else {
- 			if (bufcache < 5 || bufcache > 95) {
- 				printf(
- 		"warning: unable to set bufcache to %d%% of RAM, using 10%%",
- 				    bufcache);
- 				bufcache = 10;
- 			}
- 			bufpages = physmem / 100 * bufcache;
- 		}
- 	}
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) & ~1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;	/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	return v;
  }
  
  long	dumplo = 0;
--- 262,276 ----
  		callout[i - 1].c_next = &callout[i];
  	callout[i - 1].c_next = NULL;
  
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  
  	/*
  	 * Set up buffers, so they can be used to read disk labels.
  	 */
  
  	bufinit();
  }
  
  long	dumplo = 0;
Index: arch/x68k/x68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x68k/x68k/machdep.c,v
retrieving revision 1.67
diff -p -c -r1.67 machdep.c
*** machdep.c	1999/05/05 13:46:20	1.67
--- machdep.c	1999/05/08 12:04:36
***************
*** 42,48 ****
   *	@(#)machdep.c	8.10 (Berkeley) 4/20/94
   */
  
- #include "opt_bufcache.h"
  #include "opt_ddb.h"
  #include "opt_inet.h"
  #include "opt_atalk.h"
--- 42,47 ----
***************
*** 54,60 ****
  #include "opt_fpuemulate.h"
  #include "opt_m060sp.h"
  #include "opt_panicbutton.h"
- #include "opt_sysv.h"
  #include "opt_extmem.h"
  
  #include <sys/param.h>
--- 53,58 ----
***************
*** 81,95 ****
  #include <sys/syscallargs.h>
  #include <sys/core.h>
  #include <sys/kcore.h>
- #ifdef SYSVMSG
- #include <sys/msg.h>
- #endif
- #ifdef SYSVSEM
- #include <sys/sem.h>
- #endif
- #ifdef SYSVSHM
- #include <sys/shm.h>
- #endif
  
  #include <machine/db_machdep.h>
  #include <ddb/db_sym.h>
--- 79,84 ----
*************** vm_map_t phys_map = NULL;
*** 135,159 ****
  extern paddr_t avail_start, avail_end;
  extern vaddr_t virtual_avail;
  
! /*
!  * Declare these as initialized data so we can patch them.
!  */
! int	nswbuf = 0;
! #ifdef	NBUF
! int	nbuf = NBUF;
! #else
! int	nbuf = 0;
! #endif
! #ifdef	BUFPAGES
! int	bufpages = BUFPAGES;
! #else
! int	bufpages = 0;
! #endif
! #ifdef BUFCACHE
! int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
! #else
! int	bufcache = 0;		/* fallback to old algorithm */
! #endif
  
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
--- 124,132 ----
  extern paddr_t avail_start, avail_end;
  extern vaddr_t virtual_avail;
  
! extern caddr_t		 allocsys __P((caddr_t));
! extern const char	*format_memory __P((int64_t));
! extern int		 nbuf, nswbuf;
  
  caddr_t	msgbufaddr;
  int	maxmem;			/* max memory per process */
*************** void
*** 262,268 ****
  cpu_startup()
  {
  	unsigned i;
! 	caddr_t v, firstaddr;
  	int base, residual;
  	vaddr_t minaddr, maxaddr;
  	vsize_t size;
--- 235,241 ----
  cpu_startup()
  {
  	unsigned i;
! 	caddr_t v;
  	int base, residual;
  	vaddr_t minaddr, maxaddr;
  	vsize_t size;
*************** cpu_startup()
*** 296,404 ****
  	 */
  	printf(version);
  	identifycpu();
! 	printf("real mem  = %d\n", ctob(physmem));
! 
! 	/*
! 	 * Allocate space for system data structures.
! 	 * The first available real memory address is in "firstaddr".
! 	 * The first available kernel virtual address is in "v".
! 	 * As pages of kernel virtual memory are allocated, "v" is incremented.
! 	 * As pages of memory are allocated and cleared,
! 	 * "firstaddr" is incremented.
! 	 * An index into the kernel page table corresponding to the
! 	 * virtual memory address maintained in "v" is kept in "mapaddr".
! 	 */
! 	/*
! 	 * Make two passes.  The first pass calculates how much memory is
! 	 * needed and allocates it.  The second pass assigns virtual
! 	 * addresses to the various data structures.
! 	 */
! 	firstaddr = 0;
! again:
! 	v = (caddr_t)firstaddr;
! 
! #define	valloc(name, type, num) \
! 	    (name) = (type *)v; v = (caddr_t)((name)+(num))
! #define	valloclim(name, type, num, lim) \
! 	    (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
! 
! 	valloc(callout, struct callout, ncallout);
! #ifdef SYSVSHM
! 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
! #endif
! #ifdef SYSVSEM
! 	valloc(sema, struct semid_ds, seminfo.semmni);
! 	valloc(sem, struct sem, seminfo.semmns);
! 	/* This is pretty disgusting! */
! 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
! #endif
! #ifdef SYSVMSG
! 	valloc(msgpool, char, msginfo.msgmax);
! 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
! 	valloc(msghdrs, struct msg, msginfo.msgtql);
! 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
! #endif
! 	
! 	if (bufpages == 0) {
! 		if (bufcache == 0) {		/* use old algorithm */
! 			/*
! 			 * Determine how many buffers to allocate.
! 			 * Since an x68k tends to be long on memory and short
! 			 * on disk speed, we allocate more buffer space than
! 			 * the BSD standard of use 10% of memory for the first
! 			 * 2 Meg, 5% of remaining.
! 			 * We just allocate a flat 10%.  Insure a minimum of 16
! 			 * buffers.
! 			 * We allocate 1/2 as many swap buffer headers as file
! 			 * i/o buffers.
! 			 */
! 			bufpages = physmem / 10 / CLSIZE;
! 			if (physmem < btoc(2 * 1024 * 1024))
! 				bufpages = physmem / 10 / CLSIZE;
! 			else
! 				bufpages = (btoc(2 * 1024 * 1024) + physmem) /
! 				    (20 * CLSIZE);
! 		} else {
! 			/*
! 			 * Set size of buffer cache to physmem/bufcache * 100
! 			 * (i.e., bufcache % of physmem).
! 			 */
! 			if (bufcache < 5 || bufcache > 95) {
! 				printf(
! 		"warning: unable to set bufcache to %d%% of RAM, using 10%%",
! 				    bufcache);
! 				bufcache = 10;
! 			}
! 			bufpages= physmem / (CLSIZE * 100) * bufcache;
! 		}
! 	}
  
- 	if (nbuf == 0) {
- 		nbuf = bufpages;
- 		if (nbuf < 16)
- 			nbuf = 16;
- 	}
- 	if (nswbuf == 0) {
- 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
- 		if (nswbuf > 256)
- 			nswbuf = 256;		/* sanity */
- 	}
- 	valloc(buf, struct buf, nbuf);
- 	/*
- 	 * End of first pass, size has been calculated so allocate memory
- 	 */
- 	if (firstaddr == 0) {
- 		size = (vsize_t)(v - firstaddr);
- 		firstaddr = (caddr_t) uvm_km_zalloc(kernel_map, round_page(size));
- 		if (firstaddr == 0)
- 			panic("startup: no room for tables");
- 		goto again;
- 	}
  	/*
! 	 * End of second pass, addresses have been assigned
  	 */
! 	if ((vsize_t)(v - firstaddr) != size)
  		panic("startup: table size inconsistency");
  	/*
  	 * Now allocate buffers proper.  They are different than the above
  	 * in that they usually occupy more virtual memory than physical.
--- 269,286 ----
  	 */
  	printf(version);
  	identifycpu();
! 	printf("total memory = %s\n", format_memory(ctob(physmem)));
  
  	/*
! 	 * Find out how much space we need, allocate it,
! 	 * and then give everything true virtual addresses.
  	 */
! 	size = (vm_size_t)allocsys((caddr_t)0);
! 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! 		panic("startup: no room for tables");
! 	if (allocsys(v) - v != size)
  		panic("startup: table size inconsistency");
+ 
  	/*
  	 * Now allocate buffers proper.  They are different than the above
  	 * in that they usually occupy more virtual memory than physical.
*************** again:
*** 478,486 ****
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail mem = %ld\n", ptoa(uvmexp.free));
! 	printf("using %d buffers containing %d bytes of memory\n",
! 		nbuf, bufpages * CLBYTES);
  	/*
  	 * Set up CPU-specific registers, cache, etc.
  	 */
--- 360,368 ----
  #ifdef DEBUG
  	pmapdebug = opmapdebug;
  #endif
! 	printf("avail memory = %s\n", format_memory(ptoa(uvmexp.free)));
! 	printf("using %d buffers containing %s of memory\n",
! 	    nbuf, format_memory(bufpages * CLBYTES));
  	/*
  	 * Set up CPU-specific registers, cache, etc.
  	 */
Index: conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.288
diff -p -c -r1.288 files
*** files	1999/05/06 15:31:42	1.288
--- files	1999/05/08 12:04:38
*************** deffs	fs_coda.h CODA
*** 98,107 ****
  defopt	QUOTA
  defopt	opt_ffs.h	FFS_EI LIFFS
  
- # Not entirely MI, but present on multiple arch's
  # buffer cache size options
  defopt	opt_bufcache.h	BUFCACHE BUFPAGES
  
  # PC-style MBR handling
  defopt	opt_mbr.h	COMPAT_386BSD_MBRPART BIOS_VERBOSE
  
--- 98,109 ----
  defopt	QUOTA
  defopt	opt_ffs.h	FFS_EI LIFFS
  
  # buffer cache size options
  defopt	opt_bufcache.h	BUFCACHE BUFPAGES
  
+ 
+ # Not entirely MI, but present on multiple arch's
+ 
  # PC-style MBR handling
  defopt	opt_mbr.h	COMPAT_386BSD_MBRPART BIOS_VERBOSE
  
*************** file kern/exec_subr.c
*** 535,540 ****
--- 537,543 ----
  file kern/init_main.c
  file kern/init_sysent.c
  file kern/kern_acct.c
+ file kern/kern_allocsys.c
  file kern/kern_clock.c
  file kern/kern_descrip.c
  file kern/kern_exec.c
Index: conf/param.c
===================================================================
RCS file: /cvsroot/src/sys/conf/param.c,v
retrieving revision 1.29
diff -p -c -r1.29 param.c
*** param.c	1999/04/26 21:53:59	1.29
--- param.c	1999/05/08 12:04:38
*************** struct	msginfo msginfo = {
*** 169,180 ****
  #endif
  
  /*
-  * These are initialized at bootstrap time
-  * to values dependent on memory size
-  */
- int	nbuf, nswbuf;
- 
- /*
   * These have to be allocated somewhere; allocating
   * them here forces loader errors if this file is omitted
   * (if they've been externed everywhere else; hah!).
--- 169,174 ----
*************** struct	utsname utsname;
*** 191,207 ****
   * amount of CPU time expires.  AUTONICETIME is in seconds.
   * AUTONICEVAL is NOT offset by NZERO, i.e. it's between PRIO_MIN and PRIO_MAX.
   */
! #ifdef AUTONICETIME
! int autonicetime = AUTONICETIME;
! #else
! int autonicetime = (60 * 10);	/* 10 minutes */
  #endif
  
! #ifdef AUTONICEVAL
! int autoniceval = AUTONICEVAL;
! #else
! int autoniceval = 4;		/* default + 4 */
  #endif
  
  /*
   * Actual network mbuf sizes (read-only), for netstat.
--- 185,200 ----
   * amount of CPU time expires.  AUTONICETIME is in seconds.
   * AUTONICEVAL is NOT offset by NZERO, i.e. it's between PRIO_MIN and PRIO_MAX.
   */
! #ifndef AUTONICETIME
! #define AUTONICETIME (60 * 10)	/* 10 minutes */
  #endif
  
! #ifndef AUTONICEVAL
! #define AUTONICEVAL 4		/* default + 4 */
  #endif
+ 
+ int autonicetime = AUTONICETIME;
+ int autoniceval = AUTONICEVAL;
  
  /*
   * Actual network mbuf sizes (read-only), for netstat.
Index: kern/kern_allocsys.c
===================================================================
RCS file: kern_allocsys.c
diff -N kern_allocsys.c
*** /dev/null	Sat May  8 05:04:54 1999
--- kern_allocsys.c	Sat May  8 09:37:07 1999
***************
*** 0 ****
--- 1,207 ----
+ /*	$NetBSD$	*/
+ 
+ /*-
+  * Copyright (c) 1999 The NetBSD Foundation, Inc.
+  * All rights reserved.
+  *
+  * This code is derived from software contributed to The NetBSD Foundation
+  * by Luke Mewburn.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *	This product includes software developed by the NetBSD
+  *	Foundation, Inc. and its contributors.
+  * 4. Neither the name of The NetBSD Foundation nor the names of its
+  *    contributors may be used to endorse or promote products derived
+  *    from this software without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  * POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+ #include "opt_bufcache.h"
+ #include "opt_sysv.h"
+ 
+ #include <sys/param.h>
+ #include <sys/systm.h>
+ #include <sys/buf.h>
+ #include <sys/callout.h>
+ #ifdef SYSVMSG
+ #include <sys/msg.h>
+ #endif
+ #ifdef SYSVSEM
+ #include <sys/sem.h>
+ #endif
+ #ifdef SYSVSHM
+ #include <sys/shm.h>
+ #endif
+ 
+ #include <vm/vm.h>
+ #include <vm/vm_page.h>
+ 
+ caddr_t		 allocsys __P((caddr_t));
+ const char	*format_memory __P((int64_t));
+ 
+ /*
+  * Declare these as initialized data so we can patch them.
+  */
+ #ifndef	NBUF
+ # define NBUF 0
+ #endif
+ 
+ #ifndef	BUFPAGES
+ # define BUFPAGES 0
+ #endif
+ 
+ #ifdef BUFCACHE
+ # if (BUFCACHE < 5) || (BUFCACHE > 95)
+ #  error BUFCACHE is not between 5 and 95
+ # endif
+ #else
+ # define BUFCACHE 0
+ #endif
+ 
+ int	nswbuf = 0;
+ int	nbuf = NBUF;
+ int	bufpages = BUFPAGES;	/* optional hardwired count */
+ int	bufcache = BUFCACHE;	/* % of RAM to use for buffer cache */
+ 
+ /*
+  * Allocate space for system data structures.  We are given
+  * a starting virtual address and we return a final virtual
+  * address; along the way we set each data structure pointer.
+  *
+  * We call allocsys() with 0 to find out how much space we want,
+  * allocate that much and fill it with zeroes, and then call
+  * allocsys() again with the correct base virtual address.
+  *
+  * XXX: deviations from MD code
+  *	- amiga, atari, and mac68k used 3/4 swap vs file I/O headers
+  *	- sparc uses different method of limiting max memory
+  *	- use alpha's method of determining bufpages:
+  *		bufpages = physmem / CLSIZE * bufcache / 100;
+  * 	  instead of i386's of:
+  *		bufpages = physmem / (CLSIZE * 100) * bufcache;
+  */
+ 
+ caddr_t
+ allocsys(v)
+ 	caddr_t v;
+ {
+ 
+ #define	valloc(name, type, num) \
+ 	    (name) = (type *)v; v = (caddr_t)ALIGN((name)+(num))
+ 
+ 	valloc(callout, struct callout, ncallout);
+ #ifdef SYSVSHM
+ 	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
+ #endif
+ #ifdef SYSVSEM
+ 	valloc(sema, struct semid_ds, seminfo.semmni);
+ 	valloc(sem, struct sem, seminfo.semmns);
+ 	/* This is pretty disgusting! */
+ 	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
+ #endif
+ #ifdef SYSVMSG
+ 	valloc(msgpool, char, msginfo.msgmax);
+ 	valloc(msgmaps, struct msgmap, msginfo.msgseg);
+ 	valloc(msghdrs, struct msg, msginfo.msgtql);
+ 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
+ #endif
+ 
+ 	/*
+ 	 * Determine how many buffers to allocate.
+ 	 * We allocate bufcache % of memory for buffer space.
+ 	 */
+ 
+ 	if (bufpages == 0)
+ 		bufpages = physmem / CLSIZE * bufcache / 100;	/* alpha */
+ 
+ #ifdef DIAGNOSTIC
+ 	if (bufpages == 0)
+ 		panic("bufpages = 0\n");
+ #endif
+ 
+ 	/* 
+ 	 * Ensure a minimum of 16 buffers.
+ 	 */
+ 	if (nbuf == 0) {
+ 		nbuf = bufpages;
+ 		if (nbuf < 16)
+ 			nbuf = 16;
+ 	}
+ 
+ 	/*
+ 	 * XXX stopgap measure to prevent wasting too much KVM on
+ 	 * the sparsely filled buffer cache.
+ 	 */
+ 	if (nbuf * MAXBSIZE > VM_MAX_KERNEL_BUF)
+ 		nbuf = VM_MAX_KERNEL_BUF / MAXBSIZE;
+ #if defined (__sparc__)		/* XXX */
+ 	if (CPU_ISSUN4C && bufpages > (128 * (65536/MAXBSIZE)))
+ 		bufpages = (128 * (65536/MAXBSIZE));
+ #endif
+ 
+ 	/*
+ 	 * We allocate 1/2 as many swap buffer headers as file I/O buffers.
+ 	 */
+ 	if (nswbuf == 0) {
+ 		nswbuf = (nbuf / 2) &~ 1;	/* force even */
+ 		if (nswbuf > 256)
+ 			nswbuf = 256;		/* sanity */
+ 	}
+ 	valloc(buf, struct buf, nbuf);
+ 
+ #if defined(__alpha__)			/* XXX */
+ 	/*
+ 	 * There appears to be a correlation between the number
+ 	 * of processor slots defined in the HWRPB and the whami
+ 	 * value that can be returned.
+ 	 */
+ 	valloc(mchkinfo_all_cpus, struct mchkinfo, hwrpb->rpb_pcs_cnt);
+ #endif
+ 
+ #if defined(__sparc64__)		/* XXX */
+ 	/*
+ 	 * Allocate DVMA slots for 1/4 of the number of I/O buffers
+ 	 * and one for each process too (PHYSIO).
+ 	 */
+ 	valloc(dvmamap, struct map, ndvmamap = maxproc + ((nbuf / 4) &~ 1));
+ #endif
+ 
+ 	return (v);
+ }
+ 
+ const char *
+ format_memory(count)
+ 	int64_t	count;
+ {
+ 		/*
+ 		 * large enough buffer for:
+ 		 *	"18014398509481984 KB (18446744073709551616 bytes)"
+ 		 * i.e.,
+ 		 *	2^54 KB (2^64 bytes)
+ 		 */
+ 	static char pbuf[80];	
+ 
+ 	snprintf(pbuf, sizeof(pbuf) - 1, "%qd KB (%qd bytes)",
+ 	    (long long)(count / 1024), (long long) count);
+ 	return (pbuf);
+ }