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

Submitted by Kirill Tkhai on May 4, 2017, 4:06 p.m.

Details

Message ID 149391399285.11711.33622863736362364.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai May 4, 2017, 4:06 p.m.
Currently this is refactoring, as only level == 1 is allowed.

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

Patch hide | download patch | download mbox

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) {