Subject: Re: System crash with too much memory
To: None <darcy@NetBSD.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 04/23/2003 14:29:53
[ On Wednesday, April 23, 2003 at 13:33:10 (-0400), D'Arcy J.M. Cain wrote: ]
> Subject: Re: System crash with too much memory
>
> On Tuesday 22 April 2003 11:52, Jason Thorpe wrote:
> > It should be capping the amount of KVA used for buffers, but this is
> > clearly not working.  I wonder if the problem is the amount of KVA
> > being used for vm_page structures :-/
> 
> OK, more information.  As I said in an earlier message the value of nbuf is 
> 50810.  I modified sys/kern/kern_allocsys.c as follows:
> 
>     /*
>      * Ensure a minimum of 16 buffers.
>      */
>     if (nbuf == 0) {
>         nbuf = bufpages;
>         if (nbuf < 16)
>             nbuf = 16;
>         if (nbuf > 8000) nbuf = 8000;            /* XXX Added */
>     }
> 
> Now when I boot with 4GB it boots but when I check the number of buffers it is 
> still 6144.  It seems that it is failing in some intermediate step but 
> ultimately 6144 is still the largest size.  So does this seem like the right 
> fix for this problem?  Should 8000 be replaced with a macro constant?

When you say you "check the number of buffers", what exactly do you mean
by that?

Perhaps this will help:

Index: kern_allocsys.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/kern/kern_allocsys.c,v
retrieving revision 1.18
diff -c -r1.18 kern_allocsys.c
*** kern_allocsys.c     12 Nov 2001 15:25:05 -0000      1.18
--- kern_allocsys.c     25 Jun 2002 17:32:26 -0000
***************
*** 206,213 ****
         * 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
  
        /*
--- 206,216 ----
         * XXX stopgap measure to prevent wasting too much KVM on
         * the sparsely filled buffer cache.
         */
!       if (nbuf * MAXBSIZE > VM_MAX_KERNEL_BUF) {
!               printf("nbuf at %d is too large for VM_MAX_KERNEL_BUF... ", nbuf);
                nbuf = VM_MAX_KERNEL_BUF / MAXBSIZE;
+               printf("adjusted to %d\n", nbuf);
+       }
  #endif
  
        /*


-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>