tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Autotuning of kern.ipc.shmmaxpgs
Hi all,
currently the maximum size of SysV shared memory is limited by a static
MD limit. The attached patch allows platforms to not specify such a
limit. If the kernel config doesn't specify one either, the kernel will
compute a limit on startup based on physmem. Platforms with limited KVA
can also set SHMMAX_AUTO_LIMIT, which places an upper boundary on the
auto-tuned value.
The old limit is too restrictive for desktop and e.g. PostgreSQL users.
Comments? Other platforms that should be added to this list?
The patch is intended for pullup.
Joerg
Index: arch/amd64/include/vmparam.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/arch/amd64/include/vmparam.h,v
retrieving revision 1.20
diff -u -p -r1.20 vmparam.h
--- arch/amd64/include/vmparam.h 13 Dec 2008 14:07:10 -0000 1.20
+++ arch/amd64/include/vmparam.h 22 Feb 2009 20:03:52 -0000
@@ -105,13 +105,6 @@
#endif
/*
- * Size of shared memory map
- */
-#ifndef SHMMAXPGS
-#define SHMMAXPGS 2048
-#endif
-
-/*
* Size of User Raw I/O map
*/
#define USRIOSIZE 300
Index: arch/i386/include/vmparam.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/arch/i386/include/vmparam.h,v
retrieving revision 1.69
diff -u -p -r1.69 vmparam.h
--- arch/i386/include/vmparam.h 13 Dec 2008 14:07:10 -0000 1.69
+++ arch/i386/include/vmparam.h 22 Feb 2009 21:54:29 -0000
@@ -86,13 +86,6 @@
#define I386_MAX_EXE_ADDR (USRSTACK - MAXSSIZ)
/*
- * Size of shared memory map
- */
-#ifndef SHMMAXPGS
-#define SHMMAXPGS 2048
-#endif
-
-/*
* Size of User Raw I/O map
*/
#define USRIOSIZE 300
Index: conf/param.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/conf/param.c,v
retrieving revision 1.59
diff -u -p -r1.59 param.c
--- conf/param.c 12 Nov 2008 14:32:34 -0000 1.59
+++ conf/param.c 22 Feb 2009 20:21:47 -0000
@@ -151,8 +151,10 @@ int mcllowat = MCLLOWAT;
* Values in support of System V compatible shared memory. XXX
*/
#ifdef SYSVSHM
-#ifndef SHMMAX
+#if !defined(SHMMAX) && defined(SHMMAXPGS)
#define SHMMAX SHMMAXPGS /* shminit() performs a `*= PAGE_SIZE'
*/
+#elif !defined(SHMMAX)
+#define SHMMAX 0
#endif
#ifndef SHMMIN
#define SHMMIN 1
@@ -163,14 +165,13 @@ int mcllowat = MCLLOWAT;
#ifndef SHMSEG
#define SHMSEG 128
#endif
-#define SHMALL SHMMAXPGS
struct shminfo shminfo = {
SHMMAX,
SHMMIN,
SHMMNI,
SHMSEG,
- SHMALL
+ 0
};
#endif
Index: kern/sysv_shm.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/kern/sysv_shm.c,v
retrieving revision 1.115
diff -u -p -r1.115 sysv_shm.c
--- kern/sysv_shm.c 11 Jan 2009 02:45:53 -0000 1.115
+++ kern/sysv_shm.c 23 Feb 2009 13:39:14 -0000
@@ -973,7 +973,16 @@ shminit(void)
shm_cv = (void *)((uintptr_t)shmsegs +
ALIGN(shminfo.shmmni * sizeof(struct shmid_ds)));
- shminfo.shmmax *= PAGE_SIZE;
+ if (shminfo.shmmax == 0) {
+ shminfo.shmmax = physmem / 4 * PAGE_SIZE;
+#ifdef SHMMAX_AUTO_LIMIT
+ if (shminfo.shmmax > SHMMAX_AUTO_LIMIT)
+ shminfo.shmmax = SHMMAX_AUTO_LIMIT & ~(PAGE_SIZE - 1);
+#endif
+ } else {
+ shminfo.shmmax *= PAGE_SIZE;
+ }
+ shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
for (i = 0; i < shminfo.shmmni; i++) {
cv_init(&shm_cv[i], "shmwait");
Home |
Main Index |
Thread Index |
Old Index