]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mqueue: separate mqueue default value from maximum value
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Thu, 3 May 2012 05:44:50 +0000 (15:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 May 2012 05:47:01 +0000 (15:47 +1000)
commit b231cca438 ("message queues: increase range limits") changed mqueue
default value when attr parameter is specified NULL from hard coded value
to fs.mqueue.{msg,msgsize}_max sysctl value.

This made large side effect.  When user need to use two mqueue
applications 1) using !NULL attr parameter and it require big message size
and 2) using NULL attr parameter and only need small size message, app (1)
require to raise fs.mqueue.msgsize_max and app (2) consume large memory
size even though it doesn't need.

Doug Ledford propsed to switch back it to static hard coded value.
However it also has a compatibility problem.  Some applications might
started depend on the default value is tunable.

The solution is to separate default value from maximum value.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Acked-by: Joe Korty <joe.korty@ccur.com>
Cc: Amerigo Wang <amwang@redhat.com>
Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/sysctl/fs.txt
include/linux/ipc_namespace.h
ipc/mq_sysctl.c
ipc/mqueue.c

index 9d29414db420557f8d40a7134cffc0f1b15d30c6..d4a372e75750f21037b09165f87a615930f0f92a 100644 (file)
@@ -267,6 +267,13 @@ a queue must be less or equal then msg_max.
 maximum  message size value (it is every  message queue's attribute set during
 its creation).
 
+/proc/sys/fs/mqueue/msg_default is  a read/write  file for setting/getting the
+default number of messages in a queue value if attr parameter of mq_open(2) is
+NULL. If it exceed msg_max, the default value is initialized msg_max.
+
+/proc/sys/fs/mqueue/msgsize_default is a read/write file for setting/getting
+the default message size value if attr parameter of mq_open(2) is NULL. If it
+exceed msgsize_max, the default value is initialized msgsize_max.
 
 4. /proc/sys/fs/epoll - Configuration options for the epoll interface
 --------------------------------------------------------
index 2488535a32a383e9d8fdd04a8f9fc41ae265de09..5499c92a91539afcc0987d49fe6477acad2d16e4 100644 (file)
@@ -62,6 +62,8 @@ struct ipc_namespace {
        unsigned int    mq_queues_max;   /* initialized to DFLT_QUEUESMAX */
        unsigned int    mq_msg_max;      /* initialized to DFLT_MSGMAX */
        unsigned int    mq_msgsize_max;  /* initialized to DFLT_MSGSIZEMAX */
+       unsigned int    mq_msg_default;
+       unsigned int    mq_msgsize_default;
 
        /* user_ns which owns the ipc ns */
        struct user_namespace *user_ns;
index e22336a09b4a7932c0a5de4615fb4c7de9a98687..383d638340b8417c8e31f53b935f8e8d833b2707 100644 (file)
@@ -73,6 +73,24 @@ static ctl_table mq_sysctls[] = {
                .extra1         = &msg_maxsize_limit_min,
                .extra2         = &msg_maxsize_limit_max,
        },
+       {
+               .procname       = "msg_default",
+               .data           = &init_ipc_ns.mq_msg_default,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_mq_dointvec_minmax,
+               .extra1         = &msg_max_limit_min,
+               .extra2         = &msg_max_limit_max,
+       },
+       {
+               .procname       = "msgsize_default",
+               .data           = &init_ipc_ns.mq_msgsize_default,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_mq_dointvec_minmax,
+               .extra1         = &msg_maxsize_limit_min,
+               .extra2         = &msg_maxsize_limit_max,
+       },
        {}
 };
 
index 6b67122d887bd5f63970666373d96a12a8420754..1e4487fd0405558c328cc4181d3dfd9f5912dc31 100644 (file)
@@ -143,9 +143,10 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
                info->qsize = 0;
                info->user = NULL;      /* set when all is ok */
                memset(&info->attr, 0, sizeof(info->attr));
-               info->attr.mq_maxmsg = min(ipc_ns->mq_msg_max, DFLT_MSG);
-               info->attr.mq_msgsize =
-                       min(ipc_ns->mq_msgsize_max, DFLT_MSGSIZE);
+               info->attr.mq_maxmsg = min(ipc_ns->mq_msg_max,
+                                          ipc_ns->mq_msg_default);
+               info->attr.mq_msgsize = min(ipc_ns->mq_msgsize_max,
+                                           ipc_ns->mq_msgsize_default);
                if (attr) {
                        info->attr.mq_maxmsg = attr->mq_maxmsg;
                        info->attr.mq_msgsize = attr->mq_msgsize;
@@ -1255,6 +1256,8 @@ int mq_init_ns(struct ipc_namespace *ns)
        ns->mq_queues_max    = DFLT_QUEUESMAX;
        ns->mq_msg_max       = DFLT_MSGMAX;
        ns->mq_msgsize_max   = DFLT_MSGSIZEMAX;
+       ns->mq_msg_default   = DFLT_MSG;
+       ns->mq_msgsize_default  = DFLT_MSGSIZE;
 
        ns->mq_mnt = kern_mount_data(&mqueue_fs_type, ns);
        if (IS_ERR(ns->mq_mnt)) {