[CRIU] [PATCH] ns: Dump namespaces in parallel

Pavel arsbum at mail.ru
Mon Sep 22 05:28:52 PDT 2014


The main reason for this is -- dumping namespace has a lot of
points when the process just waits for something. At the same
time criu process wait for the ns dumper and doesn't dump
others.

The great example of waiting for something is setns syscall.
Very often it calls synchronize_rcu() which can be quite long.
Let other processes do smth useful while this.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 namespaces.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/namespaces.c b/namespaces.c
index e73760c..d15f1ba 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -459,7 +459,7 @@ int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
 {
 	struct pid *ns_pid = &item->pid;
 	struct ns_id *ns;
-	int pid, status;
+	int pid, nr = 0;
 	int ret = 0;
 
 	/*
@@ -504,8 +504,14 @@ int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
 			exit(ret);
 		}
 
-		ret = waitpid(pid, &status, 0);
-		if (ret != pid) {
+		nr++;
+	}
+
+	while (nr > 0) {
+		int status;
+
+		ret = waitpid(-1, &status, 0);
+		if (ret < 0) {
 			pr_perror("Can't wait ns dumper");
 			return -1;
 		}
@@ -514,6 +520,8 @@ int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
 			pr_err("Namespaces dumping finished with error %d\n", status);
 			return -1;
 		}
+
+		nr--;
 	}
 
 	pr_info("Namespaces dump complete\n");
-- 
1.8.4.2



More information about the CRIU mailing list