aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ipc.h2
-rw-r--r--ipc/msg.c21
2 files changed, 12 insertions, 11 deletions
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 96988d1460da..408696ea5189 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -111,6 +111,8 @@ struct ipc_namespace {
111 int msg_ctlmax; 111 int msg_ctlmax;
112 int msg_ctlmnb; 112 int msg_ctlmnb;
113 int msg_ctlmni; 113 int msg_ctlmni;
114 atomic_t msg_bytes;
115 atomic_t msg_hdrs;
114 116
115 size_t shm_ctlmax; 117 size_t shm_ctlmax;
116 size_t shm_ctlall; 118 size_t shm_ctlall;
diff --git a/ipc/msg.c b/ipc/msg.c
index 4f1f26393501..ccf5f495db7b 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -66,9 +66,6 @@ struct msg_sender {
66#define SEARCH_NOTEQUAL 3 66#define SEARCH_NOTEQUAL 3
67#define SEARCH_LESSEQUAL 4 67#define SEARCH_LESSEQUAL 4
68 68
69static atomic_t msg_bytes = ATOMIC_INIT(0);
70static atomic_t msg_hdrs = ATOMIC_INIT(0);
71
72static struct ipc_ids init_msg_ids; 69static struct ipc_ids init_msg_ids;
73 70
74#define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS])) 71#define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS]))
@@ -88,6 +85,8 @@ static void __msg_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids)
88 ns->msg_ctlmax = MSGMAX; 85 ns->msg_ctlmax = MSGMAX;
89 ns->msg_ctlmnb = MSGMNB; 86 ns->msg_ctlmnb = MSGMNB;
90 ns->msg_ctlmni = MSGMNI; 87 ns->msg_ctlmni = MSGMNI;
88 atomic_set(&ns->msg_bytes, 0);
89 atomic_set(&ns->msg_hdrs, 0);
91 ipc_init_ids(ids); 90 ipc_init_ids(ids);
92} 91}
93 92
@@ -293,10 +292,10 @@ static void freeque(struct ipc_namespace *ns, struct msg_queue *msq)
293 struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list); 292 struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list);
294 293
295 tmp = tmp->next; 294 tmp = tmp->next;
296 atomic_dec(&msg_hdrs); 295 atomic_dec(&ns->msg_hdrs);
297 free_msg(msg); 296 free_msg(msg);
298 } 297 }
299 atomic_sub(msq->q_cbytes, &msg_bytes); 298 atomic_sub(msq->q_cbytes, &ns->msg_bytes);
300 security_msg_queue_free(msq); 299 security_msg_queue_free(msq);
301 ipc_rcu_putref(msq); 300 ipc_rcu_putref(msq);
302} 301}
@@ -463,8 +462,8 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
463 down_read(&msg_ids(ns).rw_mutex); 462 down_read(&msg_ids(ns).rw_mutex);
464 if (cmd == MSG_INFO) { 463 if (cmd == MSG_INFO) {
465 msginfo.msgpool = msg_ids(ns).in_use; 464 msginfo.msgpool = msg_ids(ns).in_use;
466 msginfo.msgmap = atomic_read(&msg_hdrs); 465 msginfo.msgmap = atomic_read(&ns->msg_hdrs);
467 msginfo.msgtql = atomic_read(&msg_bytes); 466 msginfo.msgtql = atomic_read(&ns->msg_bytes);
468 } else { 467 } else {
469 msginfo.msgmap = MSGMAP; 468 msginfo.msgmap = MSGMAP;
470 msginfo.msgpool = MSGPOOL; 469 msginfo.msgpool = MSGPOOL;
@@ -735,8 +734,8 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
735 list_add_tail(&msg->m_list, &msq->q_messages); 734 list_add_tail(&msg->m_list, &msq->q_messages);
736 msq->q_cbytes += msgsz; 735 msq->q_cbytes += msgsz;
737 msq->q_qnum++; 736 msq->q_qnum++;
738 atomic_add(msgsz, &msg_bytes); 737 atomic_add(msgsz, &ns->msg_bytes);
739 atomic_inc(&msg_hdrs); 738 atomic_inc(&ns->msg_hdrs);
740 } 739 }
741 740
742 err = 0; 741 err = 0;
@@ -840,8 +839,8 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
840 msq->q_rtime = get_seconds(); 839 msq->q_rtime = get_seconds();
841 msq->q_lrpid = task_tgid_vnr(current); 840 msq->q_lrpid = task_tgid_vnr(current);
842 msq->q_cbytes -= msg->m_ts; 841 msq->q_cbytes -= msg->m_ts;
843 atomic_sub(msg->m_ts, &msg_bytes); 842 atomic_sub(msg->m_ts, &ns->msg_bytes);
844 atomic_dec(&msg_hdrs); 843 atomic_dec(&ns->msg_hdrs);
845 ss_wakeup(&msq->q_senders, 0); 844 ss_wakeup(&msq->q_senders, 0);
846 msg_unlock(msq); 845 msg_unlock(msq);
847 break; 846 break;