diff options
Diffstat (limited to 'ipc/msg.c')
-rw-r--r-- | ipc/msg.c | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/msg.h> | 27 | #include <linux/msg.h> |
28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/mm.h> | ||
30 | #include <linux/proc_fs.h> | 31 | #include <linux/proc_fs.h> |
31 | #include <linux/list.h> | 32 | #include <linux/list.h> |
32 | #include <linux/security.h> | 33 | #include <linux/security.h> |
@@ -77,11 +78,45 @@ static int newque(struct ipc_namespace *, struct ipc_params *); | |||
77 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it); | 78 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it); |
78 | #endif | 79 | #endif |
79 | 80 | ||
81 | /* | ||
82 | * Scale msgmni with the available lowmem size: the memory dedicated to msg | ||
83 | * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. | ||
84 | * This should be done staying within the (MSGMNI , IPCMNI) range. | ||
85 | */ | ||
86 | static void recompute_msgmni(struct ipc_namespace *ns) | ||
87 | { | ||
88 | struct sysinfo i; | ||
89 | unsigned long allowed; | ||
90 | |||
91 | si_meminfo(&i); | ||
92 | allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) | ||
93 | / MSGMNB; | ||
94 | |||
95 | if (allowed < MSGMNI) { | ||
96 | ns->msg_ctlmni = MSGMNI; | ||
97 | goto out_callback; | ||
98 | } | ||
99 | |||
100 | if (allowed > IPCMNI) { | ||
101 | ns->msg_ctlmni = IPCMNI; | ||
102 | goto out_callback; | ||
103 | } | ||
104 | |||
105 | ns->msg_ctlmni = allowed; | ||
106 | |||
107 | out_callback: | ||
108 | |||
109 | printk(KERN_INFO "msgmni has been set to %d for ipc namespace %p\n", | ||
110 | ns->msg_ctlmni, ns); | ||
111 | } | ||
112 | |||
80 | void msg_init_ns(struct ipc_namespace *ns) | 113 | void msg_init_ns(struct ipc_namespace *ns) |
81 | { | 114 | { |
82 | ns->msg_ctlmax = MSGMAX; | 115 | ns->msg_ctlmax = MSGMAX; |
83 | ns->msg_ctlmnb = MSGMNB; | 116 | ns->msg_ctlmnb = MSGMNB; |
84 | ns->msg_ctlmni = MSGMNI; | 117 | |
118 | recompute_msgmni(ns); | ||
119 | |||
85 | atomic_set(&ns->msg_bytes, 0); | 120 | atomic_set(&ns->msg_bytes, 0); |
86 | atomic_set(&ns->msg_hdrs, 0); | 121 | atomic_set(&ns->msg_hdrs, 0); |
87 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); | 122 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); |