[CRIU] [PATCH 2/3] pstree: Link pid and pstree_item

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jan 25 07:28:54 PST 2017


Add a link from task's pid to pstree_item.
Threads have this link set in NULL.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/include/pid.h |    1 +
 criu/pstree.c      |    2 ++
 criu/seize.c       |    2 ++
 3 files changed, 5 insertions(+)

diff --git a/criu/include/pid.h b/criu/include/pid.h
index aa9d50248..772508f96 100644
--- a/criu/include/pid.h
+++ b/criu/include/pid.h
@@ -5,6 +5,7 @@
 #include "rbtree.h"
 
 struct pid {
+	struct pstree_item *item;
 	/*
 	 * The @real pid is used to fetch tasks during dumping stage,
 	 * This is a global pid seen from the context where the dumping
diff --git a/criu/pstree.c b/criu/pstree.c
index b66116d7f..af298b831 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -218,6 +218,7 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 	item->pid.real = -1;
 	item->born_sid = -1;
 	futex_init(&item->task_st);
+	item->pid.item = item;
 
 	return item;
 }
@@ -556,6 +557,7 @@ static int read_pstree_image(pid_t *pid_max)
 			pi->threads[i].real = -1;
 			pi->threads[i].virt = e->threads[i];
 			pi->threads[i].state = TASK_THREAD;
+			pi->threads[i].item = NULL;
 			if (i == 0)
 				continue; /* A thread leader is in a tree already */
 			node = lookup_create_pid(pi->threads[i].virt, &pi->threads[i]);
diff --git a/criu/seize.c b/criu/seize.c
index a1cf49708..21821f51f 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -697,6 +697,7 @@ static int collect_threads(struct pstree_item *item)
 	if (item->nr_threads == 0) {
 		item->threads[0].real = item->pid.real;
 		item->nr_threads = 1;
+		item->threads[0].item = NULL;
 	}
 
 	nr_inprogress = 0;
@@ -734,6 +735,7 @@ static int collect_threads(struct pstree_item *item)
 
 		BUG_ON(item->nr_threads + 1 > nr_threads);
 		item->threads[item->nr_threads].real = pid;
+		item->threads[item->nr_threads].item = NULL;
 		item->nr_threads++;
 
 		if (ret == TASK_DEAD) {



More information about the CRIU mailing list