Subject: Re: NKMEMCLUSTERS?
To: Sean Sweda <sweda@netcommandos.com>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: current-users
Date: 02/21/1998 11:48:52
On Thu, 19 Feb 1998 19:20:58 -0500 
 Sean Sweda <sweda@netcommandos.com> wrote:

 > I tried to increase the size of the buffer cache, using the following
 > kernel config options:
 > 
 > options NBUF=512
 > options BUFPAGES=512
 > 
 > So instead of getting 204 pages using 835584 bytes, I should get
 > 512 pages using 2097152 bytes.  However, from what I can tell, this
 > does not work properly.  I've traced the "problem" to this line of
 > code in /usr/src/sys/arch/mac68k/mac68k/machdep.c:
 > 
 > 
 >         if (bufpages == 0)
 >                 if (physmem < btoc(2 * 1024 * 1024))
 >                         bufpages = physmem / 10 / CLSIZE;
 >                 else
 >                         bufpages = (btoc(2 * 1024 * 1024) + physmem) / 20 / CLSIZE;
 > 
 >         bufpages = min(NKMEMCLUSTERS * 2 / 5, bufpages);
 > 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Ack!  This code is incorrect!  NKMEMCLUSTERS should not change the
configuration of the buffer cache!

I discussed this problem w/ Ignatios Souvatzis when he was working on
fixing a panic on the Amiga port when the buffer cache was large.  The
problem that the above code is attempting to solve is that you run out
of kernel PT pages when you have to map a large buffer cache.  The correct
solution is to allocate more kernel PT pages when you have a larger
buffer cache, not to limit it by a constant that has nothing to do with
the buffer cache at all.

 > 
 > What is this NKMEMCLUSTERS constant?  Where does it get set?  Why does
 > it override the BUFPAGES option?
 > 
 > here is the brief description in the options man page:
 > 
 >      options NKMEMCLUSTERS=value
 >      number of slots in the kernel submap "kmem_map".  [Better description,
 >      please? Chris CGD had some comments that I didn't understand.] Default is
 >      <look this up>.  Increase this value if you get "out of space in
 >      kmem_map" panics.
 > 
 > 
 > So, what's going on here?
 > 
 > Sean
 > 
 > - ---
 > Sean Sweda
 > sweda@ibl.org                     http://www.ibl.org/~sweda 
 > sweda@netcommandos.com            http://advantage.netcommandos.com 
 > 
 > 
 > ------- End of Forwarded Message
 > 

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-5                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 415 428 6939