[Crash-utility] [PATCH v3 4/9] task_init: don't abuse pc->program_pid if !LOCAL_ACTIVE()

Oleg Nesterov oleg at redhat.com
Tue May 3 17:36:08 UTC 2016


Use pid == 1 and /sbin/init as tt->this_task instead, pc->program_pid can't
be used.

We could probably leave tt->this_task = NO_TASK, but we need to initialize
CURRENT_CONTEXT() anyway and we need something for refresh_context(), to me
"init" looks better than (say) FIRST_CONTEXT() == swapper/0.

However, this means that /init/sbin will be always reported as "active", see
the next patch.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 task.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/task.c b/task.c
index 7b01951..fd4b700 100644
--- a/task.c
+++ b/task.c
@@ -124,7 +124,6 @@ task_init(void)
 	long tss_offset, thread_offset; 
 	long eip_offset, esp_offset, ksp_offset;
 	struct gnu_request req;
-	ulong active_pid;
 
 	if (!(tt->idle_threads = (ulong *)calloc(NR_CPUS, sizeof(ulong))))
 		error(FATAL, "cannot malloc idle_threads array");
@@ -493,7 +492,9 @@ task_init(void)
 		tt->flags &= ~(TASK_REFRESH|TASK_REFRESH_OFF);
 
 	if (ACTIVE()) {
-		active_pid = REMOTE() ? pc->server_pid : pc->program_pid; 
+		ulong active_pid = REMOTE() ? pc->server_pid :
+				   LOCAL_ACTIVE() ? pc->program_pid :
+				   1;
 		set_context(NO_TASK, active_pid);
 		tt->this_task = pid_to_task(active_pid);
 	}
-- 
2.5.0




More information about the Crash-utility mailing list