From: Anton Blanchard I've debugged a number of problems which have turned out to be bad shmmax and shmall settings. The default for shmmax of 32MB is way too low these days. To further complicate matters, shmmax is in bytes but shmall is in pages. Considering some architectures (eg ia64) has a variable base page size, an interface in pages is a bad idea. Too late now. Is there a reason we set the defaults so low? Cant our VM handle shared memory just fine? If so we should just initialise these defaults to something sane. In this patch I set it to cover all of memory which means we should never see one of these fails again. Signed-off-by: Anton Blanchard Signed-off-by: Andrew Morton --- 25-akpm/include/linux/shm.h | 10 +++++----- 25-akpm/ipc/shm.c | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff -puN include/linux/shm.h~bad-ipc-shared-memory-defaults include/linux/shm.h --- 25/include/linux/shm.h~bad-ipc-shared-memory-defaults 2004-11-21 16:00:44.536708984 -0800 +++ 25-akpm/include/linux/shm.h 2004-11-21 16:00:44.542708072 -0800 @@ -6,14 +6,14 @@ #include /* - * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can - * be increased by sysctl + * SHMMNI sets the maximum number of shared memory segments and can be + * increased via the shmmni sysctl. Both shmmax (which specifies the maximum + * amount of memory in bytes per shared memory segment) and shmall (which + * specifiies the maximum amount of shared memory in pages across all + * processes) is sized at runtime based on total memory. */ - -#define SHMMAX 0x2000000 /* max shared seg size (bytes) */ #define SHMMIN 1 /* min shared seg size (bytes) */ #define SHMMNI 4096 /* max num of segs system wide */ -#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ #define SHMSEG SHMMNI /* max shared segs per process */ #include diff -puN ipc/shm.c~bad-ipc-shared-memory-defaults ipc/shm.c --- 25/ipc/shm.c~bad-ipc-shared-memory-defaults 2004-11-21 16:00:44.538708680 -0800 +++ 25-akpm/ipc/shm.c 2004-11-21 16:00:44.543707920 -0800 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "util.h" @@ -51,14 +52,17 @@ static void shm_close (struct vm_area_st static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); #endif -size_t shm_ctlmax = SHMMAX; -size_t shm_ctlall = SHMALL; +size_t shm_ctlmax; +size_t shm_ctlall; int shm_ctlmni = SHMMNI; static int shm_tot; /* total number of shared memory pages */ void __init shm_init (void) { + shm_ctlmax = nr_all_pages * PAGE_SIZE; + shm_ctlall = nr_all_pages; + ipc_init_ids(&shm_ids, 1); #ifdef CONFIG_PROC_FS create_proc_read_entry("sysvipc/shm", 0, NULL, sysvipc_shm_read_proc, NULL); _