The msg_bytes and msg_hdrs atomic counters are frequently
updated when IPC msg queue is in heavy use, causing heavy
cache bounce and overhead. Change them to percpu_counters
greatly improve the performance. Since there is one unique
ipc namespace, additional memory cost is minimal.
@@ -1303,14 +1305,16 @@ void msg_init_ns(struct ipc_namespace *ns)
ns->msg_ctlmnb = MSGMNB;
ns->msg_ctlmni = MSGMNI;
- atomic_set(&ns->msg_bytes, 0);
- atomic_set(&ns->msg_hdrs, 0);
+ percpu_counter_init(&ns->percpu_msg_bytes, 0, GFP_KERNEL);
+ percpu_counter_init(&ns->percpu_msg_hdrs, 0, GFP_KERNEL);
ipc_init_ids(&ns->ids[IPC_MSG_IDS]);