Subject: Small tweak to buf pool page allocator
To: None <tech-kern@netbsd.org>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 01/09/2004 11:07:01
--Apple-Mail-24-878740738
Content-Type: multipart/mixed; boundary=Apple-Mail-23-878740734


--Apple-Mail-23-878740734
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

In the current scheme, systems that have direct-mapped segments for 
PAGE_SIZE pool pages can't take advantage of those for the buffer 
cache.  This small tweak would allow them to so do.

Seem OK?

         -- Jason R. Thorpe <thorpej@wasabisystems.com>

--Apple-Mail-23-878740734
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	x-unix-mode=0644;
	name="buf-allocator-patch.txt"
Content-Disposition: attachment;
	filename=buf-allocator-patch.txt

Index: vfs_bio.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_bio.c,v
retrieving revision 1.107
diff -u -r1.107 vfs_bio.c
--- vfs_bio.c	9 Jan 2004 19:01:01 -0000	1.107
+++ vfs_bio.c	9 Jan 2004 19:04:49 -0000
@@ -331,7 +331,7 @@
 bufinit(void)
 {
 	struct bqueues *dp;
-	int smallmem;
+	int use_std;
 	u_int i;
 
 	/*
@@ -361,7 +361,15 @@
 	pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", NULL);
 
 	/* On "small" machines use small pool page sizes where possible */
-	smallmem = (physmem < atop(16*1024*1024));
+	use_std = (physmem < atop(16*1024*1024));
+
+	/*
+	 * Also use them on systems that can map the pool pages using
+	 * a direct-mapped segment.
+	 */
+#ifdef PMAP_MAP_POOLPAGE
+	use_std = 1;
+#endif
 
 	for (i = 0; i < NMEMPOOLS; i++) {
 		struct pool_allocator *pa;
@@ -369,7 +377,7 @@
 		u_int size = 1 << (i + MEMPOOL_INDEX_OFFSET);
 		char *name = malloc(8, M_TEMP, M_WAITOK);
 		snprintf(name, 8, "buf%dk", 1 << i);
-		pa = (size <= PAGE_SIZE && smallmem)
+		pa = (size <= PAGE_SIZE && use_std)
 			? &pool_allocator_nointr
 			: &bufmempool_allocator;
 		pool_init(pp, size, 0, 0, PR_IMMEDRELEASE, name, pa);

--Apple-Mail-23-878740734--

--Apple-Mail-24-878740738
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQE//vvVOpVKkaBm8XkRAnKGAKCx65zgJ0qC2qtcUQN2u2Ojzils+wCfQa2F
khxStdshIQBt4WdET2f3r/I=
=idfe
-----END PGP SIGNATURE-----

--Apple-Mail-24-878740738--