Commit b231cca4381ee15ec99afbfb244fbc0324869927

Authored by Joe Korty
Committed by Linus Torvalds
1 parent acd99dbf54

message queues: increase range limits

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.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 14 additions and 6 deletions Side-by-side Diff

... ... @@ -52,6 +52,14 @@
52 52 #define HARD_MSGMAX (131072/sizeof(void*))
53 53 #define DFLT_MSGSIZEMAX 8192 /* max message size */
54 54  
  55 +/*
  56 + * Define the ranges various user-specified maximum values can
  57 + * be set to.
  58 + */
  59 +#define MIN_MSGMAX 1 /* min value for msg_max */
  60 +#define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
  61 +#define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
  62 +#define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
55 63  
56 64 struct ext_wait_queue { /* queue of sleeping tasks */
57 65 struct task_struct *task;
... ... @@ -134,8 +142,8 @@
134 142 info->qsize = 0;
135 143 info->user = NULL; /* set when all is ok */
136 144 memset(&info->attr, 0, sizeof(info->attr));
137   - info->attr.mq_maxmsg = DFLT_MSGMAX;
138   - info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
  145 + info->attr.mq_maxmsg = msg_max;
  146 + info->attr.mq_msgsize = msgsize_max;
139 147 if (attr) {
140 148 info->attr.mq_maxmsg = attr->mq_maxmsg;
141 149 info->attr.mq_msgsize = attr->mq_msgsize;
142 150  
... ... @@ -1191,11 +1199,11 @@
1191 1199 .kill_sb = kill_litter_super,
1192 1200 };
1193 1201  
1194   -static int msg_max_limit_min = DFLT_MSGMAX;
1195   -static int msg_max_limit_max = HARD_MSGMAX;
  1202 +static int msg_max_limit_min = MIN_MSGMAX;
  1203 +static int msg_max_limit_max = MAX_MSGMAX;
1196 1204  
1197   -static int msg_maxsize_limit_min = DFLT_MSGSIZEMAX;
1198   -static int msg_maxsize_limit_max = INT_MAX;
  1205 +static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
  1206 +static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
1199 1207  
1200 1208 static ctl_table mq_sysctls[] = {
1201 1209 {