All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Manfred Spraul <manfred@colorfullife.com>, linux-kernel@vger.kernel.org
Subject: [patch 1/3] ipc: rename IPCMNI to IPCMNI_MAX
Date: Thu, 20 May 2010 16:59:11 +1000	[thread overview]
Message-ID: <20100520065911.GG2516@laptop> (raw)

Hi,

Just a couple of small IPC patches I have, I wonder if you could
comment on or merge?

--
The IPCMNI limit is different from the other MNI limits. It is not exposed
to userspace, it is not tunable via sysctl -- it is a hard limit. Rename it
to IPCMNI_MAX, to signify it is a maximum rather than default value.

It is an internal value tied to IPC sequence numbering, so move it into
ipc/util.h.

Index: linux-2.6/include/linux/ipc.h
===================================================================
--- linux-2.6.orig/include/linux/ipc.h
+++ linux-2.6/include/linux/ipc.h
@@ -80,8 +80,6 @@ struct ipc_kludge {
 #ifdef __KERNEL__
 #include <linux/spinlock.h>
 
-#define IPCMNI 32768  /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
-
 /* used by in-kernel data structures */
 struct kern_ipc_perm
 {
Index: linux-2.6/include/linux/msg.h
===================================================================
--- linux-2.6.orig/include/linux/msg.h
+++ linux-2.6/include/linux/msg.h
@@ -55,11 +55,11 @@ struct msginfo {
  * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
  * up to 8MB       : msgmni = 16 (MSGMNI)
  * 4 GB            : msgmni = 8K
- * more than 16 GB : msgmni = 32K (IPCMNI)
+ * more than 16 GB : msgmni = 32K (IPCMNI_MAX)
  */
 #define MSG_MEM_SCALE 32
 
-#define MSGMNI    16   /* <= IPCMNI */     /* max # of msg queue identifiers */
+#define MSGMNI    16   /* <= IPCMNI_MAX */ /* max # of msg queue identifiers */
 #define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
 #define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
 
Index: linux-2.6/include/linux/sem.h
===================================================================
--- linux-2.6.orig/include/linux/sem.h
+++ linux-2.6/include/linux/sem.h
@@ -63,7 +63,7 @@ struct  seminfo {
 	int semaem;
 };
 
-#define SEMMNI  128             /* <= IPCMNI  max # of semaphore identifiers */
+#define SEMMNI  128             /* <= IPCMNI_MAX  max semaphore identifiers */
 #define SEMMSL  250             /* <= 8 000 max num of semaphores per id */
 #define SEMMNS  (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
 #define SEMOPM  32	        /* <= 1 000 max num of ops per semop call */
Index: linux-2.6/include/linux/shm.h
===================================================================
--- linux-2.6.orig/include/linux/shm.h
+++ linux-2.6/include/linux/shm.h
@@ -14,15 +14,15 @@
  * be increased by sysctl
  */
 
-#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 SHMMAX 0x2000000	 /* max shared seg size (bytes) */
+#define SHMMIN 1		 /* min shared seg size (bytes) */
+#define SHMMNI 4096		 /* <= IPCMNI_MAX max num of segs system wide */
 #ifdef __KERNEL__
 #define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
 #else
 #define SHMALL (SHMMAX/getpagesize()*(SHMMNI/16))
 #endif
-#define SHMSEG SHMMNI			 /* max shared segs per process */
+#define SHMSEG SHMMNI		 /* max shared segs per process */
 
 #ifdef __KERNEL__
 #include <asm/shmparam.h>
Index: linux-2.6/ipc/msg.c
===================================================================
--- linux-2.6.orig/ipc/msg.c
+++ linux-2.6/ipc/msg.c
@@ -81,7 +81,7 @@ static int sysvipc_msg_proc_show(struct
  * Scale msgmni with the available lowmem size: the memory dedicated to msg
  * queues should occupy at most 1/MSG_MEM_SCALE of lowmem.
  * Also take into account the number of nsproxies created so far.
- * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range.
+ * This should be done staying within the (MSGMNI , IPCMNI_MAX/nr_ipc_ns) range.
  */
 void recompute_msgmni(struct ipc_namespace *ns)
 {
@@ -100,8 +100,8 @@ void recompute_msgmni(struct ipc_namespa
 		return;
 	}
 
-	if (allowed > IPCMNI / nb_ns) {
-		ns->msg_ctlmni = IPCMNI / nb_ns;
+	if (allowed > IPCMNI_MAX / nb_ns) {
+		ns->msg_ctlmni = IPCMNI_MAX / nb_ns;
 		return;
 	}
 
Index: linux-2.6/ipc/util.c
===================================================================
--- linux-2.6.orig/ipc/util.c
+++ linux-2.6/ipc/util.c
@@ -113,7 +113,7 @@ __initcall(ipc_init);
  *	@ids: Identifier set
  *
  *	Set up the sequence range to use for the ipc identifier range (limited
- *	below IPCMNI) then initialise the ids idr.
+ *	below IPCMNI_MAX) then initialise the ids idr.
  */
  
 void ipc_init_ids(struct ipc_ids *ids)
@@ -218,12 +218,12 @@ int ipc_get_maxid(struct ipc_ids *ids)
 	if (ids->in_use == 0)
 		return -1;
 
-	if (ids->in_use == IPCMNI)
-		return IPCMNI - 1;
+	if (ids->in_use == IPCMNI_MAX)
+		return IPCMNI_MAX - 1;
 
 	/* Look for the last assigned id */
 	total = 0;
-	for (id = 0; id < IPCMNI && total < ids->in_use; id++) {
+	for (id = 0; id < IPCMNI_MAX && total < ids->in_use; id++) {
 		ipc = idr_find(&ids->ipcs_idr, id);
 		if (ipc != NULL) {
 			max_id = id;
@@ -253,8 +253,8 @@ int ipc_addid(struct ipc_ids* ids, struc
 	gid_t egid;
 	int id, err;
 
-	if (size > IPCMNI)
-		size = IPCMNI;
+	if (size > IPCMNI_MAX)
+		size = IPCMNI_MAX;
 
 	if (ids->in_use >= size)
 		return -ENOSPC;
@@ -859,7 +859,7 @@ static struct kern_ipc_perm *sysvipc_fin
 	if (total >= ids->in_use)
 		return NULL;
 
-	for ( ; pos < IPCMNI; pos++) {
+	for ( ; pos < IPCMNI_MAX; pos++) {
 		ipc = idr_find(&ids->ipcs_idr, pos);
 		if (ipc != NULL) {
 			*new_pos = pos + 1;
Index: linux-2.6/ipc/util.h
===================================================================
--- linux-2.6.orig/ipc/util.h
+++ linux-2.6/ipc/util.h
@@ -13,7 +13,9 @@
 #include <linux/unistd.h>
 #include <linux/err.h>
 
-#define SEQ_MULTIPLIER	(IPCMNI)
+#define IPCMNI_MAX 32768  /* <= MAX_INT absolute limit for ipc arrays */
+
+#define SEQ_MULTIPLIER	(IPCMNI_MAX)
 
 void sem_init (void);
 void msg_init (void);

             reply	other threads:[~2010-05-20  6:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20  6:59 Nick Piggin [this message]
2010-05-20  7:00 ` [patch 2/3] ipc: use shifts to extract seq/idx Nick Piggin
2010-05-20 18:16   ` Manfred Spraul
2010-05-21  1:33     ` Nick Piggin
2010-05-20  7:07 ` [patch 3/3] ipc: increase IPCMNI_MAX Nick Piggin
2010-05-21 20:31   ` Andrew Morton
2010-05-24  7:43     ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100520065911.GG2516@laptop \
    --to=npiggin@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.