Subject: Re: unable to boot with 256MB of RAM
To: Curt Sampson <cjs@cynic.net>
From: Eduardo E. Horvath <eeh@one-o.com>
List: port-sparc
Date: 11/19/1999 13:59:23
> My solution, which wasn't totally optimal but would make all machines
> boot, is to check at boot time the amount of VM allocated to buffers
> (MAXBSIZE * NBUF) and, if it's too large for the machine, reduce
> NBUF until MAXBSIZE * NBUF is not too large.

The simple solution is to restrict the buffer cache to some fraction
of the kernel address space.  Since the kernel address space remains
fixed regardless of the machine's memory, you really shouldn't need to
tune this much.  The only problem that can occur is when other
structures, like the page array, start getting too large.

In fact, allocsys already has the hooks to do this:

#ifdef VM_MAX_KERNEL_BUF
        /*
         * 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;
#endif

kern_allocsys.c includes sys/param.h which includes machine/param.h So
all we need to do is include machine/vmparam.h in machine/param.h
(_KERNEL only) and define VM_MAX_KERNEL_BUF like this:

#ifdef	_KERNEL
#include	<machine/vmparam.h>
/* Arbitrarily only use 1/4 of the kernel address space for buffers. */
#define	VM_MAX_KERNEL_BUF	((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS)/4)
#endif

(Or, alternatively rename VM_MAX_KERNEL_ADDRESS to KERNEND and move it
into machine/param.h, and define VM_MAX_KERNEL_ADDRESS in terms of
KERNEND:

machine/param.h:

#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE)
extern int nbpg, pgofset, pgshift;
#endif

#define KERNBASE        0xf0000000      /* start of kernel virtual space */
+#define KERNEND	0xfe000000	/* end of kernel virtual space */
+/* Arbitrarily only use 1/4 of the kernel address space for buffers. */
+#define VM_MAX_KERNEL_BUF       ((KERNEND - KERNBASE)/4)
#define PROM_LOADADDR   0x00004000      /* where the prom loads us */
#define KERNTEXTOFF     (KERNBASE+PROM_LOADADDR)/* start of kernel text */

machine/vmparam.h:


/*
 * User/kernel map constants.  Note that sparc/vaddrs.h defines the
 * IO space virtual base, which must be the same as VM_MAX_KERNEL_ADDRESS:
 * tread with care.
 */
#define VM_MIN_ADDRESS          ((vaddr_t)0)
#define VM_MAX_ADDRESS          ((vaddr_t)KERNBASE)
#define VM_MAXUSER_ADDRESS      ((vaddr_t)KERNBASE)
#define VM_MIN_KERNEL_ADDRESS   ((vaddr_t)KERNBASE)
-#define VM_MAX_KERNEL_ADDRESS   ((vaddr_t)0xfe000000)
+#define VM_MAX_KERNEL_ADDRESS   ((vaddr_t)KERNEND)

Actually, I think this is cleaner.)


=========================================================================
Eduardo Horvath				eeh@one-o.com
	"I need to find a pithy new quote." -- me