Subject: Re: Autosizing NVNODE
To: None <abs@netbsd.org>
From: MAEKAWA Masahide <gehenna@daemon-systems.org>
List: tech-kern
Date: 01/30/2003 09:08:37
David Brownlee <abs@netbsd.org> wrote:
>	NVNODE defaults to (NPROC + NTEXT + 100), which is generally
>	way too small on a machine running in any kind of fileserving
>	capacity. It can be set in a kernel config, but that can make
>	sharing a kernel between machines with widely different memory
>	values difficult.

The value of (NPROC + NTEXT + 100) may be small, but NVNODE is not.

NVNODE is stored in desiredvnodes @ sys/conf/param.c.
If you don't set NVNODE explicitly, desiredvnodes
is re-calculated @ sys/kern/init_main.c.

#ifdef NVNODE_IMPLICIT
        /*
         * If maximum number of vnodes in namei vnode cache is not explicitly
         * defined in kernel config, adjust the number such as we use roughly
         * 0.5% of memory for vnode cache (but not less than NVNODE vnodes).
         */
        usevnodes = (ptoa((unsigned)physmem) / 200) / sizeof(struct vnode);
        if (usevnodes > desiredvnodes)
                desiredvnodes = usevnodes;
#endif

If you still believe that desiredvnodes is small,
Please try this patch.

http://www.daemon-systems.org/dev/maxusers.diff.bz2

After this patch,
If you set 'maxusers' to 0 or remove 'maxusers' line in your kernel
configuration file, that value is calculated from total memory on your machine
automatically at boot-time, and all values which depends on 'maxusers' is too.
(of course, including vnodes).

That result is:

Before: (maxusers 32 : the default value in GENERIC - NetBSD/i386)

NetBSD 1.6M (TEST) #2: Wed Jan 22 23:27:47 JST 2003
    maekawa@lucifer.daemon-systems.org:/home/maekawa/work/netbsd-syssrc/sys/arch
/i386/compile/TEST
total memory = 191 MB
avail memory = 170 MB
using 2477 buffers containing 9908 KB of memory
maxusers=32, maxproc=532, vnodes=6276, maxfiles=1772, ncallout=548

After: (maxusers 0)

NetBSD 1.6M (TEST2) #3: Thu Jan 23 00:08:08 JST 2003
    maekawa@lucifer.daemon-systems.org:/home/maekawa/work/netbsd-syssrc/sys/arch
/i386/compile/TEST2
total memory = 191 MB
avail memory = 170 MB
using 2477 buffers containing 9908 KB of memory
maxusers=96, maxproc=1556, vnodes=6276, maxfiles=5036, ncallout=1572

'maxusers' is set to (memory / 2) in this patch.

Well, vnodes is same after this patch. maybe not so small.

--- MAEKAWA Masahide
--- Key fingerprint = BC5E D8CB 816C 2CB5 8560  FDE3 6CB8 BF5D 8D50 F2EE