lkml.org 
[lkml]   [2004]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectBad IPC shared memory defaults

Hi,

Ive 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.

Anton

Signed-off-by: Anton Blanchard <anton@samba.org>

diff -puN include/linux/shm.h~shm_fixes include/linux/shm.h
--- gr_work/include/linux/shm.h~shm_fixes 2004-11-20 16:56:29.972061609 -0600
+++ gr_work-anton/include/linux/shm.h 2004-11-20 16:56:30.013054658 -0600
@@ -6,14 +6,14 @@
#include <asm/page.h>

/*
- * 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 <asm/shmparam.h>
diff -puN ipc/shm.c~shm_fixes ipc/shm.c
--- gr_work/ipc/shm.c~shm_fixes 2004-11-20 16:56:30.003056354 -0600
+++ gr_work-anton/ipc/shm.c 2004-11-20 16:58:13.334244383 -0600
@@ -27,6 +27,7 @@
#include <linux/shmem_fs.h>
#include <linux/security.h>
#include <linux/syscalls.h>
+#include <linux/bootmem.h>
#include <asm/uaccess.h>

#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);
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.032 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site