mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Korty <joe.korty@ccur.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>, Al Viro <aviro@redhat.com>
Subject: [PATCH] message queues: increase range limits
Date: Wed, 27 Aug 2008 13:48:45 -0400	[thread overview]
Message-ID: <20080827174845.GA27509@tsunami.ccur.com> (raw)

Increase the range of various posix message queue limits.

Posix gives the message queue user the ability to 'trade
off' the maximum size of messages with the number of
possible messages that can be 'in flight'.  Linux currently
makes this trade off more restrictive than it needs to be.

In particular, the maximum message size today can be
made no smaller than 8192.  This greatly restricts those
applications that would like to have the ability to post
large numbers of very small messages.

So this task lowers the limit that the maximum message
size can be set to, from 8192 to 128.  It also lowers the
limit that the maximum #number of messages in flight can
be set to, from 10 to 1.

With these changes the message queue user can make better
trade offs between #messages and message size, in order to
get everything to fit within the setrlimit(RLIMIT_MSGQUEUE)
limit for that particular user.

This patch also applies the values in

	/proc/sys/fs/mqueue/msg_max
	/proc/sys/fs/mqueue/msgsize_max

as the defaults for the max #messages allowed and the max
message size allowed, respectively, for those applications
that do not supply these.  Previously, the defaults were
hardwired to 10 and 8192, respectively.

Signed-off-by: Joe Korty <joe.korty@ccur.com>

Index: 2.6.27-rc4-git4/ipc/mqueue.c
===================================================================
--- 2.6.27-rc4-git4.orig/ipc/mqueue.c	2008-08-26 17:44:35.000000000 -0400
+++ 2.6.27-rc4-git4/ipc/mqueue.c	2008-08-27 13:36:12.000000000 -0400
@@ -52,6 +52,14 @@
 #define HARD_MSGMAX 	(131072/sizeof(void*))
 #define DFLT_MSGSIZEMAX 8192	/* max message size */
 
+/*
+ * Define the ranges various user-specified maximum values can
+ * be set to.
+ */
+#define MIN_MSGMAX	1		/* min value for msg_max */
+#define MAX_MSGMAX	HARD_MSGMAX	/* max value for msg_max */
+#define MIN_MSGSIZEMAX	128		/* min value for msgsize_max */
+#define MAX_MSGSIZEMAX	8192*128	/* max value for msgsize_max */
 
 struct ext_wait_queue {		/* queue of sleeping tasks */
 	struct task_struct *task;
@@ -134,8 +142,8 @@
 			info->qsize = 0;
 			info->user = NULL;	/* set when all is ok */
 			memset(&info->attr, 0, sizeof(info->attr));
-			info->attr.mq_maxmsg = DFLT_MSGMAX;
-			info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
+			info->attr.mq_maxmsg = msg_max;
+			info->attr.mq_msgsize = msgsize_max;
 			if (attr) {
 				info->attr.mq_maxmsg = attr->mq_maxmsg;
 				info->attr.mq_msgsize = attr->mq_msgsize;
@@ -1191,11 +1199,11 @@
 	.kill_sb = kill_litter_super,
 };
 
-static int msg_max_limit_min = DFLT_MSGMAX;
-static int msg_max_limit_max = HARD_MSGMAX;
+static int msg_max_limit_min = MIN_MSGMAX;
+static int msg_max_limit_max = MAX_MSGMAX;
 
-static int msg_maxsize_limit_min = DFLT_MSGSIZEMAX;
-static int msg_maxsize_limit_max = INT_MAX;
+static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
+static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
 
 static ctl_table mq_sysctls[] = {
 	{

                 reply	other threads:[~2008-08-27 17:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080827174845.GA27509@tsunami.ccur.com \
    --to=joe.korty@ccur.com \
    --cc=akpm@linux-foundation.org \
    --cc=aviro@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®