Commit 9af2eff9 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

pstree: Link pid and pstree_item

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

travis-ci: success for Make pstree_item::pid allocated dynamically
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 13a0efaf
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "rbtree.h" #include "rbtree.h"
struct pid { struct pid {
struct pstree_item *item;
/* /*
* The @real pid is used to fetch tasks during dumping stage, * The @real pid is used to fetch tasks during dumping stage,
* This is a global pid seen from the context where the dumping * This is a global pid seen from the context where the dumping
......
...@@ -216,6 +216,7 @@ struct pstree_item *__alloc_pstree_item(bool rst) ...@@ -216,6 +216,7 @@ struct pstree_item *__alloc_pstree_item(bool rst)
item->pid.virt = -1; item->pid.virt = -1;
item->pid.real = -1; item->pid.real = -1;
item->born_sid = -1; item->born_sid = -1;
item->pid.item = item;
return item; return item;
} }
...@@ -554,6 +555,7 @@ static int read_pstree_image(pid_t *pid_max) ...@@ -554,6 +555,7 @@ static int read_pstree_image(pid_t *pid_max)
pi->threads[i].real = -1; pi->threads[i].real = -1;
pi->threads[i].virt = e->threads[i]; pi->threads[i].virt = e->threads[i];
pi->threads[i].state = TASK_THREAD; pi->threads[i].state = TASK_THREAD;
pi->threads[i].item = NULL;
if (i == 0) if (i == 0)
continue; /* A thread leader is in a tree already */ continue; /* A thread leader is in a tree already */
node = lookup_create_pid(pi->threads[i].virt, &pi->threads[i]); node = lookup_create_pid(pi->threads[i].virt, &pi->threads[i]);
......
...@@ -695,6 +695,7 @@ static int collect_threads(struct pstree_item *item) ...@@ -695,6 +695,7 @@ static int collect_threads(struct pstree_item *item)
if (item->nr_threads == 0) { if (item->nr_threads == 0) {
item->threads[0].real = item->pid.real; item->threads[0].real = item->pid.real;
item->nr_threads = 1; item->nr_threads = 1;
item->threads[0].item = NULL;
} }
nr_inprogress = 0; nr_inprogress = 0;
...@@ -732,6 +733,7 @@ static int collect_threads(struct pstree_item *item) ...@@ -732,6 +733,7 @@ static int collect_threads(struct pstree_item *item)
BUG_ON(item->nr_threads + 1 > nr_threads); BUG_ON(item->nr_threads + 1 > nr_threads);
item->threads[item->nr_threads].real = pid; item->threads[item->nr_threads].real = pid;
item->threads[item->nr_threads].item = NULL;
item->nr_threads++; item->nr_threads++;
if (ret == TASK_DEAD) { if (ret == TASK_DEAD) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment