From: Dave Hansen <haveblue@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: serue@us.ibm.com, frankeh@watson.ibm.com, clg@fr.ibm.com,
Herbert Poetzl <herbert@13thfloor.at>,
Sam Vilain <sam@vilain.net>, Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 3/6] sysvmsg: containerize sysctls
Date: Mon, 06 Mar 2006 15:52:50 -0800 [thread overview]
Message-ID: <20060306235250.22981BC9@localhost.localdomain> (raw)
In-Reply-To: <20060306235248.20842700@localhost.localdomain>
Use the new sysctl data accessor function pointers to put
the sysvmsg sysctl variables inside of the context structure.
Note that this will effectively remove the system-wide limits
on sysv msg resources that the sysctl mechanism currently
provides and move it to a per-container limit. This is
currently by design, and may be later addressed when we have
proper large-scale resource controls in the kernel.
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---
work-dave/ipc/msg.c | 38 +++++++++++++++++++++++++-------------
work-dave/ipc/util.h | 4 ++++
work-dave/kernel/sysctl.c | 12 ++++++------
3 files changed, 35 insertions(+), 19 deletions(-)
diff -puN ipc/msg.c~sysvmsg-containerize-sysctls ipc/msg.c
--- work/ipc/msg.c~sysvmsg-containerize-sysctls 2006-03-06 15:41:57.000000000 -0800
+++ work-dave/ipc/msg.c 2006-03-06 15:41:57.000000000 -0800
@@ -32,11 +32,6 @@
#include <asm/uaccess.h>
#include "util.h"
-/* sysctl: */
-int msg_ctlmax = MSGMAX;
-int msg_ctlmnb = MSGMNB;
-int msg_ctlmni = MSGMNI;
-
/* one msg_receiver structure for each sleeping receiver */
struct msg_receiver {
struct list_head r_list;
@@ -76,7 +71,11 @@ static int sysvipc_msg_proc_show(struct
void __init msg_init (struct ipc_msg_context *context)
{
- ipc_init_ids(&context->ids,msg_ctlmni);
+ context->ctlmax = MSGMAX;
+ context->ctlmnb = MSGMNB;
+ context->ctlmni = MSGMNI;
+
+ ipc_init_ids(&context->ids,context->ctlmni);
ipc_init_proc_interface("sysvipc/msg",
" key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n",
&context->ids,
@@ -103,7 +102,7 @@ static int newque (struct ipc_msg_contex
return retval;
}
- id = ipc_addid(&context->ids, &msq->q_perm, msg_ctlmni);
+ id = ipc_addid(&context->ids, &msq->q_perm, context->ctlmni);
if(id == -1) {
security_msg_queue_free(msq);
ipc_rcu_putref(msq);
@@ -114,7 +113,7 @@ static int newque (struct ipc_msg_contex
msq->q_stime = msq->q_rtime = 0;
msq->q_ctime = get_seconds();
msq->q_cbytes = msq->q_qnum = 0;
- msq->q_qbytes = msg_ctlmnb;
+ msq->q_qbytes = context->ctlmnb;
msq->q_lspid = msq->q_lrpid = 0;
INIT_LIST_HEAD(&msq->q_messages);
INIT_LIST_HEAD(&msq->q_receivers);
@@ -356,9 +355,9 @@ asmlinkage long sys_msgctl (int msqid, i
return err;
memset(&msginfo,0,sizeof(msginfo));
- msginfo.msgmni = msg_ctlmni;
- msginfo.msgmax = msg_ctlmax;
- msginfo.msgmnb = msg_ctlmnb;
+ msginfo.msgmni = context->ctlmni;
+ msginfo.msgmax = context->ctlmax;
+ msginfo.msgmnb = context->ctlmnb;
msginfo.msgssz = MSGSSZ;
msginfo.msgseg = MSGSEG;
down(&context->ids.sem);
@@ -462,7 +461,7 @@ asmlinkage long sys_msgctl (int msqid, i
case IPC_SET:
{
err = -EPERM;
- if (setbuf.qbytes > msg_ctlmnb && !capable(CAP_SYS_RESOURCE))
+ if (setbuf.qbytes > context->ctlmnb && !capable(CAP_SYS_RESOURCE))
goto out_unlock_up;
msq->q_qbytes = setbuf.qbytes;
@@ -560,7 +559,7 @@ asmlinkage long sys_msgsnd (int msqid, s
int err;
struct ipc_msg_context *context = ¤t->ipc_context->msg;
- if (msgsz > msg_ctlmax || (long) msgsz < 0 || msqid < 0)
+ if (msgsz > context->ctlmax || (long) msgsz < 0 || msqid < 0)
return -EINVAL;
if (get_user(mtype, &msgp->mtype))
return -EFAULT;
@@ -835,3 +834,16 @@ static int sysvipc_msg_proc_show(struct
msq->q_ctime);
}
#endif
+
+void *msg_ctlmnb_helper(void)
+{
+ return ¤t->ipc_context->msg.ctlmnb;
+}
+void *msg_ctlmni_helper(void)
+{
+ return ¤t->ipc_context->msg.ctlmni;
+}
+void *msg_ctlmax_helper(void)
+{
+ return ¤t->ipc_context->msg.ctlmax;
+}
diff -puN ipc/util.h~sysvmsg-containerize-sysctls ipc/util.h
--- work/ipc/util.h~sysvmsg-containerize-sysctls 2006-03-06 15:41:57.000000000 -0800
+++ work-dave/ipc/util.h 2006-03-06 15:41:57.000000000 -0800
@@ -34,6 +34,10 @@ struct ipc_msg_context {
atomic_t bytes;
atomic_t hdrs;
+ int ctlmax;
+ int ctlmnb;
+ int ctlmni;
+
struct ipc_ids ids;
struct kref count;
};
diff -puN kernel/sysctl.c~sysvmsg-containerize-sysctls kernel/sysctl.c
--- work/kernel/sysctl.c~sysvmsg-containerize-sysctls 2006-03-06 15:41:57.000000000 -0800
+++ work-dave/kernel/sysctl.c 2006-03-06 15:41:57.000000000 -0800
@@ -94,10 +94,10 @@ extern int sg_big_buff;
#ifdef CONFIG_SYSVIPC
extern size_t shm_ctlmax;
extern size_t shm_ctlall;
+extern void *msg_ctlmnb_helper(void);
+extern void *msg_ctlmni_helper(void);
+extern void *msg_ctlmax_helper(void);
extern int shm_ctlmni;
-extern int msg_ctlmax;
-extern int msg_ctlmnb;
-extern int msg_ctlmni;
extern int sem_ctls[];
#endif
@@ -452,7 +452,7 @@ static ctl_table kern_table[] = {
{
.ctl_name = KERN_MSGMAX,
.procname = "msgmax",
- .data = &msg_ctlmax,
+ .data_access = &msg_ctlmax_helper,
.maxlen = sizeof (int),
.mode = 0644,
.proc_handler = &proc_dointvec,
@@ -460,7 +460,7 @@ static ctl_table kern_table[] = {
{
.ctl_name = KERN_MSGMNI,
.procname = "msgmni",
- .data = &msg_ctlmni,
+ .data_access = &msg_ctlmni_helper,
.maxlen = sizeof (int),
.mode = 0644,
.proc_handler = &proc_dointvec,
@@ -468,7 +468,7 @@ static ctl_table kern_table[] = {
{
.ctl_name = KERN_MSGMNB,
.procname = "msgmnb",
- .data = &msg_ctlmnb,
+ .data_access = &msg_ctlmnb_helper,
.maxlen = sizeof (int),
.mode = 0644,
.proc_handler = &proc_dointvec,
_
next prev parent reply other threads:[~2006-03-06 23:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-06 23:52 [RFC][PATCH 0/6] support separate namespaces for sysv Dave Hansen
2006-03-06 23:52 ` [RFC][PATCH 1/6] prepare sysctls for containers Dave Hansen
2006-03-07 0:50 ` Herbert Poetzl
2006-03-07 2:00 ` Dave Hansen
2006-03-07 2:45 ` Herbert Poetzl
2006-03-19 15:54 ` Eric W. Biederman
2006-03-07 1:01 ` Chris Wright
2006-03-07 2:04 ` Dave Hansen
2006-03-07 2:18 ` Chris Wright
2006-03-07 3:02 ` Sam Vilain
2006-03-07 1:24 ` Al Viro
2006-03-07 1:55 ` Dave Hansen
2006-03-07 1:57 ` Al Viro
2006-03-19 14:50 ` Eric W. Biederman
2006-03-19 15:29 ` Eric W. Biederman
2006-03-06 23:52 ` [RFC][PATCH 2/6] sysvmsg: containerize Dave Hansen
2006-03-07 1:57 ` Chris Wright
2006-03-07 2:08 ` Dave Hansen
2006-03-07 2:34 ` Chris Wright
2006-03-19 15:36 ` Eric W. Biederman
2006-03-20 19:34 ` Chris Wright
2006-03-20 21:29 ` Eric W. Biederman
2006-03-20 21:50 ` Chris Wright
2006-03-06 23:52 ` Dave Hansen [this message]
2006-03-06 23:52 ` [RFC][PATCH 4/6] sysvsem: containerize Dave Hansen
2006-03-07 2:44 ` Chris Wright
2006-03-07 5:08 ` Dave Hansen
2006-03-06 23:52 ` [RFC][PATCH 5/6] sysvshm: containerize Dave Hansen
2006-03-06 23:52 ` [RFC][PATCH 6/6] sysvshm: containerize sysctls Dave Hansen
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=20060306235250.22981BC9@localhost.localdomain \
--to=haveblue@us.ibm.com \
--cc=clg@fr.ibm.com \
--cc=frankeh@watson.ibm.com \
--cc=herbert@13thfloor.at \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@vilain.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox