Subject: dynamic adjusting of desiredvnodes on boot
To: None <tech-kern@netbsd.org>
From: Jaromír Doleček <dolecek@ibis.cz>
List: tech-kern
Date: 07/04/2000 18:19:51
Hi,
problem trying to solve: static & for bigger machines (ridiculously)
low number of vnodes in vnode cache.

Does anyone see anything wrong with following change ? The code
adjusts the number of vnodes so that they take roughly 0.5%
of machine total physical memory (or NVNODE if previous would
result in number less than NVNODE). Is usage of physmem variable
MI-safe ? I'm not quite sure putting this into main() is the best
thing to do, but I don't see any better MI place :(

Jaromir


Index: sys/param.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/param.h,v
retrieving revision 1.101
diff -u -r1.101 param.h
--- param.h	2000/06/30 07:44:06	1.101
+++ param.h	2000/07/04 16:09:44
@@ -131,6 +131,7 @@
 #endif
 #ifndef NVNODE
 #define	NVNODE (NPROC + NTEXT + 100)
+#define	NVNODE_IMPLICIT
 #endif
 #endif /* _KERNEL */
 
Index: kern/init_main.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/init_main.c,v
retrieving revision 1.174
diff -u -r1.174 init_main.c
--- init_main.c	2000/06/27 17:41:12	1.174
+++ init_main.c	2000/07/04 16:09:50
@@ -188,6 +188,9 @@
 #if defined(NFSSERVER) || defined(NFS)
 	extern void nfs_init __P((void));
 #endif
+#ifdef NVNODE_IMPLICIT
+	int usevnodes;
+#endif
 
 	/*
 	 * Initialize the current process pointer (curproc) before
@@ -496,6 +499,17 @@
 	 */
 	start_init_exec = 1;
 	wakeup((void *)&start_init_exec);
+
+#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(physmem) / 200) / sizeof(struct vnode);
+	if (usevnodes > desiredvnodes) 
+		desiredvnodes = usevnodes;
+#endif
 
 	/* The scheduler is an infinite loop. */
 	uvm_scheduler();
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
@@@@  Wanna a real operating system ? Go and get NetBSD, damn!  @@@@