From owner-freebsd-hackers Mon Aug 20 1:56: 5 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from peter3.wemm.org (c1315225-a.plstn1.sfba.home.com [24.14.150.180]) by hub.freebsd.org (Postfix) with ESMTP id 68F0537B406; Mon, 20 Aug 2001 01:55:34 -0700 (PDT) (envelope-from peter@wemm.org) Received: from overcee.netplex.com.au (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id f7K8tYM67829; Mon, 20 Aug 2001 01:55:34 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id 271B93905; Mon, 20 Aug 2001 01:55:34 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Matt Dillon Cc: murray@FreeBSD.ORG, jkh@FreeBSD.ORG, hackers@FreeBSD.ORG, Leo Bicknell Subject: Re: Proposed patch (-stable) for minor KVM adjustments for the release In-Reply-To: <200108192046.f7JKkkA46377@earth.backplane.com> Date: Mon, 20 Aug 2001 01:55:34 -0700 From: Peter Wemm Message-Id: <20010820085534.271B93905@overcee.netplex.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Murray/jkh, please do not approve this for MFC until the problems have been fixed. For starters, it breaks all platforms other than the i386. Matt Dillon wrote: > Here is my proposed patch. It adds to options (overrides) to the kernel > config, two boot-time tunables for same, and sets reasonable defaults. > I also changed the default auto-sizing calculation for swap-meta from > 32x physical pages to 16x physical pages on top of it being capped. > I only made a small change there since we cannot really afford to run > out of swap-meta structures (the system will probably lockup if we do). > > This patch is against -stable. I will commit it to -current today and > await the release-engineers permission to MFC it to -stable for the > release. I did some simple testing under -stable, including bumping up > maxusers and NMBCLUSTERS. > > -Matt > > Index: conf/options > =================================================================== > RCS file: /home/ncvs/src/sys/conf/options,v > retrieving revision 1.191.2.35 > diff -u -r1.191.2.35 options > --- conf/options 2001/08/03 00:47:27 1.191.2.35 > +++ conf/options 2001/08/19 20:00:29 > @@ -163,6 +163,8 @@ > NBUF opt_param.h > NMBCLUSTERS opt_param.h > NSFBUFS opt_param.h > +VM_BCACHE_SIZE_MAX opt_param.h > +VM_SWZONE_SIZE_MAX opt_param.h > MAXUSERS > > # Generic SCSI options. > Index: i386/conf/LINT > =================================================================== > RCS file: /home/ncvs/src/sys/i386/conf/Attic/LINT,v > retrieving revision 1.749.2.77 > diff -u -r1.749.2.77 LINT > --- i386/conf/LINT 2001/08/15 01:23:49 1.749.2.77 > +++ i386/conf/LINT 2001/08/19 20:27:02 > @@ -2315,7 +2315,44 @@ > # > options NSFBUFS=1024 > > +# Set the size of the buffer cache KVM reservation, in buffers. This is > +# scaled by approximately 16384 bytes. The system will auto-size the buffer > +# cache if this option is not specified or set to 0. > # > +options NBUF=512 > + > +# Set the size of the mbuf KVM reservation, in clusters. This is scaled > +# by approximately 2048 bytes. The system will auto-size the mbuf area > +# if this options is not specified or set to 0. > +# > +options NMBCLUSTERS=1024 > + > +# Tune the kernel malloc area parameters. VM_KMEM_SIZE represents the > +# minimum, in bytes, and is typically (12*1024*1024) (12MB). > +# VM_KMEM_SIZE_MAX represents the maximum, typically 200 megabytes. > +# VM_KMEM_SIZE_SCALE can be set to adjust the auto-tuning factor, which > +# typically defaults to 4 (kernel malloc area size is physical memory > +# divided by the scale factor). > +# > +options VM_KMEM_SIZE="(10*1024*1024)" > +options VM_KMEM_SIZE_MAX="(100*1024*1024)" > +options VM_KMEM_SIZE_SCALE="4" > + > +# Tune the buffer cache maximum KVA reservation, in bytes. The maximum is > +# usually capped at 200 MB, effecting machines with > 1GB of ram. Note > +# that the buffer cache only really governs write buffering and disk block > +# translations. The VM page cache is our primary disk cache and is not > +# effected by the size of the buffer cache. > +# > +options VM_BCACHE_SIZE_MAX="(100*1024*1024)" > + > +# Tune the swap zone KVA reservation, in bytes. The default is typically > +# 70 MB, giving the system the ability to manage a maximum of 28GB worth > +# of swapped out data. > +# > +options VM_SWZONE_SIZE_MAX="(50*1024*1024)" > + > +# > # Enable extra debugging code for locks. This stores the filename and > # line of whatever acquired the lock in the lock itself, and change a > # number of function calls to pass around the relevant data. This is > @@ -2500,9 +2537,7 @@ > options KEY > options LOCKF_DEBUG > options LOUTB > -options NBUF=512 > options NETATALKDEBUG > -options NMBCLUSTERS=1024 > #options OLTR_NO_BULLSEYE_MAC > #options OLTR_NO_HAWKEYE_MAC > #options OLTR_NO_TMS_MAC > @@ -2521,7 +2556,5 @@ > options SPX_HACK > options TIMER_FREQ="((14318182+6)/12)" > options VFS_BIO_DEBUG > -options VM_KMEM_SIZE > -options VM_KMEM_SIZE_MAX > -options VM_KMEM_SIZE_SCALE > options XBONEHACK > + > Index: i386/i386/machdep.c > =================================================================== > RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v > retrieving revision 1.385.2.15 > diff -u -r1.385.2.15 machdep.c > --- i386/i386/machdep.c 2001/07/30 23:27:59 1.385.2.15 > +++ i386/i386/machdep.c 2001/08/19 20:36:19 > @@ -320,7 +320,9 @@ > * The nominal buffer size (and minimum KVA allocation) is BKVASIZE. > * For the first 64MB of ram nominally allocate sufficient buffers to > * cover 1/4 of our ram. Beyond the first 64MB allocate additional > - * buffers to cover 1/20 of our ram over 64MB. > + * buffers to cover 1/20 of our ram over 64MB. When auto-sizing > + * the buffer cache we limit the eventual kva reservation to > + * maxbcache bytes. > * > * factor represents the 1/4 x ram conversion. > */ > @@ -332,6 +334,8 @@ > nbuf += min((physmem - 1024) / factor, 16384 / factor); > if (physmem > 16384) > nbuf += (physmem - 16384) * 2 / (factor * 5); > + if (maxbcache && nbuf > maxbcache / BKVASIZE) > + nbuf = maxbcache / BKVASIZE; > } > > /* > Index: i386/include/param.h > =================================================================== > RCS file: /home/ncvs/src/sys/i386/include/param.h,v > retrieving revision 1.54.2.4 > diff -u -r1.54.2.4 param.h > --- i386/include/param.h 2000/12/29 10:59:18 1.54.2.4 > +++ i386/include/param.h 2001/08/19 20:07:08 > @@ -113,6 +113,22 @@ > #define UPAGES 2 /* pages of u-area */ > > /* > + * Ceiling on amount of swblock kva space. > + */ > +#ifndef VM_SWZONE_SIZE_MAX > +#define VM_SWZONE_SIZE_MAX (70 * 1024 * 1024) > +#endif > + > +/* > + * Ceiling on size of buffer cache (really only effects write queueing, > + * the VM page cache is not effected). > + */ > +#ifndef VM_BCACHE_SIZE_MAX > +#define VM_BCACHE_SIZE_MAX (200 * 1024 * 1024) > +#endif > + > + > +/* > * Constants related to network buffer management. > * MCLBYTES must be no larger than CLBYTES (the software page size), and, > * on machines that exchange pages of input or output buffers with mbuf > Index: kern/subr_param.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/subr_param.c,v > retrieving revision 1.42.2.1 > diff -u -r1.42.2.1 subr_param.c > --- kern/subr_param.c 2001/07/30 23:28:00 1.42.2.1 > +++ kern/subr_param.c 2001/08/19 20:04:05 > @@ -76,6 +76,8 @@ > int mbuf_wait = 32; /* mbuf sleep time in ticks */ > int nbuf; > int nswbuf; > +int maxswzone; /* max swmeta KVA storage */ > +int maxbcache; /* max buffer cache KVA storage */ > > /* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */ > int nsfbufs; > @@ -115,6 +117,10 @@ > TUNABLE_INT_FETCH("kern.ipc.nsfbufs", &nsfbufs); > nbuf = NBUF; > TUNABLE_INT_FETCH("kern.nbuf", &nbuf); > + maxswzone = VM_SWZONE_SIZE_MAX; > + TUNABLE_INT_FETCH("kern.maxswzone", &maxswzone); > + maxbcache = VM_BCACHE_SIZE_MAX; > + TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache); > ncallout = 16 + maxproc + maxfiles; > TUNABLE_INT_FETCH("kern.ncallout", &ncallout); > } > Index: sys/buf.h > =================================================================== > RCS file: /home/ncvs/src/sys/sys/buf.h,v > retrieving revision 1.88.2.4 > diff -u -r1.88.2.4 buf.h > --- sys/buf.h 2001/06/03 05:00:10 1.88.2.4 > +++ sys/buf.h 2001/08/19 19:54:02 > @@ -455,6 +455,8 @@ > > #ifdef _KERNEL > extern int nbuf; /* The number of buffer headers */ > +extern int maxswzone; /* Max KVA for swap structures */ > +extern int maxbcache; /* Max KVA for buffer cache */ > extern int runningbufspace; > extern int buf_maxio; /* nominal maximum I/O for buffer */ > extern struct buf *buf; /* The buffer headers. */ > Index: vm/swap_pager.c > =================================================================== > RCS file: /home/ncvs/src/sys/vm/swap_pager.c,v > retrieving revision 1.130.2.8 > diff -u -r1.130.2.8 swap_pager.c > --- vm/swap_pager.c 2001/03/24 20:28:24 1.130.2.8 > +++ vm/swap_pager.c 2001/08/19 19:47:19 > @@ -300,10 +300,12 @@ > /* > * Initialize our zone. Right now I'm just guessing on the number > * we need based on the number of pages in the system. Each swblock > - * can hold 16 pages, so this is probably overkill. > + * can hold 16 pages, so this is probably overkill. This reservation > + * is typically limited to around 70MB by default. > */ > - > - n = cnt.v_page_count * 2; > + n = cnt.v_page_count; > + if (maxswzone && n > maxswzone / sizeof(struct swblock)) > + n = maxswzone / sizeof(struct swblock); > > swap_zone = zinit( > "SWAPMETA", > > Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message