diff options
| author | Davidlohr Bueso <davidlohr@hp.com> | 2014-06-06 17:37:45 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-06 19:08:14 -0400 |
| commit | 3440a6bd1d2eeb27276f6bd410e0902dcba09f0e (patch) | |
| tree | d1469fc45fdbad0ffe228155165b7ba433860aeb /ipc | |
| parent | f75a2f358d840e99212b1828b131e8fe8629ac43 (diff) | |
ipc,msg: move some msgq ns code around
Nothing big and no logical changes, just get rid of some redundant
function declarations. Move msg_[init/exit]_ns down the end of the
file.
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
| -rw-r--r-- | ipc/msg.c | 132 |
1 files changed, 63 insertions, 69 deletions
| @@ -70,75 +70,6 @@ struct msg_sender { | |||
| 70 | 70 | ||
| 71 | #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) | 71 | #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) |
| 72 | 72 | ||
| 73 | static void freeque(struct ipc_namespace *, struct kern_ipc_perm *); | ||
| 74 | static int newque(struct ipc_namespace *, struct ipc_params *); | ||
| 75 | #ifdef CONFIG_PROC_FS | ||
| 76 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it); | ||
| 77 | #endif | ||
| 78 | |||
| 79 | /* | ||
| 80 | * Scale msgmni with the available lowmem size: the memory dedicated to msg | ||
| 81 | * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. | ||
| 82 | * Also take into account the number of nsproxies created so far. | ||
| 83 | * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range. | ||
| 84 | */ | ||
| 85 | void recompute_msgmni(struct ipc_namespace *ns) | ||
| 86 | { | ||
| 87 | struct sysinfo i; | ||
| 88 | unsigned long allowed; | ||
| 89 | int nb_ns; | ||
| 90 | |||
| 91 | si_meminfo(&i); | ||
| 92 | allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) | ||
| 93 | / MSGMNB; | ||
| 94 | nb_ns = atomic_read(&nr_ipc_ns); | ||
| 95 | allowed /= nb_ns; | ||
| 96 | |||
| 97 | if (allowed < MSGMNI) { | ||
| 98 | ns->msg_ctlmni = MSGMNI; | ||
| 99 | return; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (allowed > IPCMNI / nb_ns) { | ||
| 103 | ns->msg_ctlmni = IPCMNI / nb_ns; | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | |||
| 107 | ns->msg_ctlmni = allowed; | ||
| 108 | } | ||
| 109 | |||
| 110 | void msg_init_ns(struct ipc_namespace *ns) | ||
| 111 | { | ||
| 112 | ns->msg_ctlmax = MSGMAX; | ||
| 113 | ns->msg_ctlmnb = MSGMNB; | ||
| 114 | |||
| 115 | recompute_msgmni(ns); | ||
| 116 | |||
| 117 | atomic_set(&ns->msg_bytes, 0); | ||
| 118 | atomic_set(&ns->msg_hdrs, 0); | ||
| 119 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); | ||
| 120 | } | ||
| 121 | |||
| 122 | #ifdef CONFIG_IPC_NS | ||
| 123 | void msg_exit_ns(struct ipc_namespace *ns) | ||
| 124 | { | ||
| 125 | free_ipcs(ns, &msg_ids(ns), freeque); | ||
| 126 | idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); | ||
| 127 | } | ||
| 128 | #endif | ||
| 129 | |||
| 130 | void __init msg_init(void) | ||
| 131 | { | ||
| 132 | msg_init_ns(&init_ipc_ns); | ||
| 133 | |||
| 134 | printk(KERN_INFO "msgmni has been set to %d\n", | ||
| 135 | init_ipc_ns.msg_ctlmni); | ||
| 136 | |||
| 137 | ipc_init_proc_interface("sysvipc/msg", | ||
| 138 | " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", | ||
| 139 | IPC_MSG_IDS, sysvipc_msg_proc_show); | ||
| 140 | } | ||
| 141 | |||
| 142 | static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) | 73 | static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) |
| 143 | { | 74 | { |
| 144 | struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id); | 75 | struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id); |
| @@ -1054,6 +985,57 @@ SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, | |||
| 1054 | return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); | 985 | return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); |
| 1055 | } | 986 | } |
| 1056 | 987 | ||
| 988 | /* | ||
| 989 | * Scale msgmni with the available lowmem size: the memory dedicated to msg | ||
| 990 | * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. | ||
| 991 | * Also take into account the number of nsproxies created so far. | ||
| 992 | * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range. | ||
| 993 | */ | ||
| 994 | void recompute_msgmni(struct ipc_namespace *ns) | ||
| 995 | { | ||
| 996 | struct sysinfo i; | ||
| 997 | unsigned long allowed; | ||
| 998 | int nb_ns; | ||
| 999 | |||
| 1000 | si_meminfo(&i); | ||
| 1001 | allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) | ||
| 1002 | / MSGMNB; | ||
| 1003 | nb_ns = atomic_read(&nr_ipc_ns); | ||
| 1004 | allowed /= nb_ns; | ||
| 1005 | |||
| 1006 | if (allowed < MSGMNI) { | ||
| 1007 | ns->msg_ctlmni = MSGMNI; | ||
| 1008 | return; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | if (allowed > IPCMNI / nb_ns) { | ||
| 1012 | ns->msg_ctlmni = IPCMNI / nb_ns; | ||
| 1013 | return; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | ns->msg_ctlmni = allowed; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | void msg_init_ns(struct ipc_namespace *ns) | ||
| 1020 | { | ||
| 1021 | ns->msg_ctlmax = MSGMAX; | ||
| 1022 | ns->msg_ctlmnb = MSGMNB; | ||
| 1023 | |||
| 1024 | recompute_msgmni(ns); | ||
| 1025 | |||
| 1026 | atomic_set(&ns->msg_bytes, 0); | ||
| 1027 | atomic_set(&ns->msg_hdrs, 0); | ||
| 1028 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | #ifdef CONFIG_IPC_NS | ||
| 1032 | void msg_exit_ns(struct ipc_namespace *ns) | ||
| 1033 | { | ||
| 1034 | free_ipcs(ns, &msg_ids(ns), freeque); | ||
| 1035 | idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); | ||
| 1036 | } | ||
| 1037 | #endif | ||
| 1038 | |||
| 1057 | #ifdef CONFIG_PROC_FS | 1039 | #ifdef CONFIG_PROC_FS |
| 1058 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it) | 1040 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it) |
| 1059 | { | 1041 | { |
| @@ -1078,3 +1060,15 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it) | |||
| 1078 | msq->q_ctime); | 1060 | msq->q_ctime); |
| 1079 | } | 1061 | } |
| 1080 | #endif | 1062 | #endif |
| 1063 | |||
| 1064 | void __init msg_init(void) | ||
| 1065 | { | ||
| 1066 | msg_init_ns(&init_ipc_ns); | ||
| 1067 | |||
| 1068 | printk(KERN_INFO "msgmni has been set to %d\n", | ||
| 1069 | init_ipc_ns.msg_ctlmni); | ||
| 1070 | |||
| 1071 | ipc_init_proc_interface("sysvipc/msg", | ||
| 1072 | " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", | ||
| 1073 | IPC_MSG_IDS, sysvipc_msg_proc_show); | ||
| 1074 | } | ||
