All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge@hallyn.com>
To: Doug Ledford <dledford@redhat.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	kosaki.motohiro@gmail.com,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Amerigo Wang <amwang@redhat.com>,
	"Serge E. Hallyn" <serue@us.ibm.com>, Jiri Slaby <jslaby@suse.cz>
Subject: Re: [Patch 7/8] mqueue: separate mqueue default value from maximum value v2
Date: Wed, 18 Apr 2012 03:30:31 +0000	[thread overview]
Message-ID: <20120418033031.GD18830@mail.hallyn.com> (raw)
In-Reply-To: <3ec3acf3b66f655a05ab05c38fe3bd2762e2c8c4.1334676645.git.dledford@redhat.com>

Quoting Doug Ledford (dledford@redhat.com):
> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> 
> 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>
> Acked-by: Doug Ledford <dledford@redhat.com>
> Acked-by: Joe Korty <joe.korty@ccur.com>
> Cc: Amerigo Wang <amwang@redhat.com>
> Cc: Serge E. Hallyn <serue@us.ibm.com>

Seems reasonable.  Thanks.

Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>

> Cc: Jiri Slaby <jslaby@suse.cz>
> 
> v1->v2: Slightly modified because msgutil.c no longer needs mq
>   namespace initialization
> 
> Signed-off-by (v2): Doug Ledford <dledford@redhat.com>
> ---
>  Documentation/sysctl/fs.txt   |    7 +++++++
>  include/linux/ipc_namespace.h |    2 ++
>  ipc/mq_sysctl.c               |   18 ++++++++++++++++++
>  ipc/mqueue.c                  |    9 ++++++---
>  4 files changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt
> index 88fd7f5..13d6166 100644
> --- a/Documentation/sysctl/fs.txt
> +++ b/Documentation/sysctl/fs.txt
> @@ -225,6 +225,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
>  --------------------------------------------------------
> diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
> index 2488535..5499c92 100644
> --- a/include/linux/ipc_namespace.h
> +++ b/include/linux/ipc_namespace.h
> @@ -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;

Mention here what they are initialized to, for completeness?

>  
>  	/* user_ns which owns the ipc ns */
>  	struct user_namespace *user_ns;
> diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
> index e22336a..383d638 100644
> --- a/ipc/mq_sysctl.c
> +++ b/ipc/mq_sysctl.c
> @@ -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,
> +	},
>  	{}
>  };
>  
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index f9f0782..04cc77e 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -142,9 +142,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;
> @@ -1254,6 +1255,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)) {
> -- 
> 1.7.7.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2012-04-18  3:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 15:46 [Patch 0/8] Fix POSIX mqueue open issue Doug Ledford
2012-04-17 15:46 ` [Patch 1/8] ipc/mqueue: cleanup definition names and locations Doug Ledford
2012-04-17 17:03   ` KOSAKI Motohiro
2012-04-18  3:14   ` Serge E. Hallyn
2012-04-17 15:46 ` [Patch 2/8] ipc/mqueue: switch back to using non-max values on create Doug Ledford
2012-04-17 22:17   ` Andrew Morton
2012-04-17 22:32     ` KOSAKI Motohiro
2012-04-17 23:00       ` Andrew Morton
2012-04-18 14:22         ` Doug Ledford
2012-04-17 15:46 ` [Patch 3/8] ipc/mqueue: enforce hard limits Doug Ledford
2012-04-17 15:46 ` [Patch 4/8] ipc/mqueue: update maximums for the mqueue subsystem Doug Ledford
2012-04-17 15:46 ` [Patch 5/8] mqueue: revert bump up DFLT_*MAX Doug Ledford
2012-04-18  3:22   ` Serge E. Hallyn
2012-04-18  3:37     ` KOSAKI Motohiro
2012-04-18 14:25     ` Doug Ledford
2012-04-18 15:33       ` Serge E. Hallyn
2012-04-17 15:46 ` [Patch 6/8] mqueue: don't use kmalloc with KMALLOC_MAX_SIZE Doug Ledford
2012-04-18  3:24   ` Serge E. Hallyn
2012-04-17 15:46 ` [Patch 7/8] mqueue: separate mqueue default value from maximum value v2 Doug Ledford
2012-04-18  3:30   ` Serge E. Hallyn [this message]
2012-04-17 15:46 ` [Patch 8/8] selftests: add mq_open_tests Doug Ledford

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=20120418033031.GD18830@mail.hallyn.com \
    --to=serge@hallyn.com \
    --cc=akpm@linux-foundation.org \
    --cc=amwang@redhat.com \
    --cc=dledford@redhat.com \
    --cc=jslaby@suse.cz \
    --cc=kosaki.motohiro@gmail.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serue@us.ibm.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.