Skip to contentSkip to conversation

ipc, mqueue: lazy call kern_mount_data in new namespaces

PATCH New Giuseppe Scrivano 1 participant 1 message Dec 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ipc, mqueue: lazy call kern_mount_data in new namespaces

kern_mount_data is a relatively expensive operation when creating a new IPC namespace, so delay the mount until its first usage when not creating the the global namespace.

This is a net saving for new IPC namespaces that don't use mq_open(). In this case there won't be any kern_mount_data() cost at all.

On my machine, the time for creating 1000 new IPC namespaces dropped from ~8s to ~2s.

---
v2->v3: rebased on top of linux-next

 include/linux/ipc_namespace.h |  4 ++--
 ipc/mqueue.c                  | 49 ++++++++++++++++++++++++++++++++++---------
 ipc/namespace.c               |  2 +-
 3 files changed, 42 insertions(+), 13 deletions(-)
include/linux/ipc_namespace.h +2 -2
index b5630c8eb2f3..554e31494f69 100644
@@ -81,7 +81,7 @@ static inline void shm_destroy_orphaned(struct ipc_namespace *ns) {}
 #endif /* CONFIG_SYSVIPC */
 
 #ifdef CONFIG_POSIX_MQUEUE
-extern int mq_init_ns(struct ipc_namespace *ns);
+extern int mq_init_ns(struct ipc_namespace *ns, bool mount);
 /*
  * POSIX Message Queue default values:
  *
@@ -116,7 +116,7 @@ extern int mq_init_ns(struct ipc_namespace *ns);
 #define DFLT_MSGSIZEMAX		     8192
 #define HARD_MSGSIZEMAX	    (16*1024*1024)
 #else
-static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
+static inline int mq_init_ns(struct ipc_namespace *ns, bool mount) { return 0; }
 #endif
 
 #if defined(CONFIG_IPC_NS)
ipc/mqueue.c +39 -10

100 lines not on this page · raw message

ipc/namespace.c +1 -1
index f59a89966f92..9d3689577f66 100644
@@ -65,7 +65,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
 	if (err)
 		goto fail_destroy_msg;
 
-	err = mq_init_ns(ns);
+	err = mq_init_ns(ns, false);
 	if (err)
 		goto fail_destroy_shm;
 
Signature · 1 line
2.14.3