Skip to content

Commit b231cca

Browse files
Joe Kortytorvalds
authored andcommitted
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>
1 parent acd99db commit b231cca

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎ipc/mqueue.c‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@
5252
#define HARD_MSGMAX (131072/sizeof(void*))
5353
#define DFLT_MSGSIZEMAX 8192 /* max message size */
5454

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 */
5563

5664
struct ext_wait_queue { /* queue of sleeping tasks */
5765
struct task_struct *task;
@@ -134,8 +142,8 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
134142
info->qsize = 0;
135143
info->user = NULL; /* set when all is ok */
136144
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;
139147
if (attr) {
140148
info->attr.mq_maxmsg = attr->mq_maxmsg;
141149
info->attr.mq_msgsize = attr->mq_msgsize;
@@ -1191,11 +1199,11 @@ static struct file_system_type mqueue_fs_type = {
11911199
.kill_sb = kill_litter_super,
11921200
};
11931201

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;
11961204

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;
11991207

12001208
static ctl_table mq_sysctls[] = {
12011209
{

0 commit comments

Comments
 (0)