[CRIU] [PATCH v4 11/41] pstree: Use thread group leader level of pid to allocate threads

Kirill Tkhai ktkhai at virtuozzo.com
Thu May 4 09:06:32 PDT 2017


Currently this is refactoring, as only level == 1 is allowed.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/seize.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/criu/seize.c b/criu/seize.c
index 5bc127717..ffc56d8ad 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -689,6 +689,7 @@ static int collect_threads(struct pstree_item *item)
 {
 	struct pid **threads = NULL;
 	int nr_threads = 0, i = 0, ret, nr_inprogress, nr_stopped = 0;
+	int level = item->pid->level;
 
 	ret = parse_threads(item->pid->real, &threads, &nr_threads);
 	if (ret < 0)
@@ -705,13 +706,13 @@ static int collect_threads(struct pstree_item *item)
 		return -1;
 
 	if (item->nr_threads == 0) {
-		item->threads[0] = xmalloc(sizeof(struct pid));
+		item->threads[0] = xmalloc(PID_SIZE(level));
 		if (!item->threads[0])
 			return -1;
 		item->threads[0]->real = item->pid->real;
 		item->nr_threads = 1;
 		item->threads[0]->item = NULL;
-		item->threads[0]->level = 1;
+		item->threads[0]->level = level;
 	}
 
 	nr_inprogress = 0;
@@ -749,12 +750,12 @@ static int collect_threads(struct pstree_item *item)
 			processes_to_wait--;
 
 		BUG_ON(item->nr_threads + 1 > nr_threads);
-		item->threads[item->nr_threads] = xmalloc(sizeof(struct pid));
+		item->threads[item->nr_threads] = xmalloc(PID_SIZE(level));
 		if (!item->threads[item->nr_threads])
 			goto err;
 		item->threads[item->nr_threads]->real = pid;
 		item->threads[item->nr_threads]->item = NULL;
-		item->threads[item->nr_threads]->level = 1;
+		item->threads[item->nr_threads]->level = level;
 		item->nr_threads++;
 
 		if (ret == TASK_DEAD) {



More information about the CRIU mailing list