[Crash-utility] [PATCH v2 23/25] modify print_task_header() to indicate idle task on offline cpu

Qiao Nuohan qiaonuohan at cn.fujitsu.com
Mon Sep 29 02:09:21 UTC 2014


Since the offline cpu is halt, the active task(idle task) on offline cpu
is not running actually. Add "<OFFLINE>" at the end of task header to
indicate such tasks.

The offline cpu is #2, and the output is changed from:
<cut>
crash> ps -l
...
[             0] [RU]  PID: 0      TASK: ffffffff818d5440  CPU: 0   COMMAND: "swapper/0"
[             0] [RU]  PID: 0      TASK: ffff88003dad4fa0  CPU: 1   COMMAND: "swapper/1"
[             0] [RU]  PID: 0      TASK: ffff88003dad5b00  CPU: 2   COMMAND: "swapper/2"
[             0] [RU]  PID: 0      TASK: ffff88003dad6660  CPU: 3   COMMAND: "swapper/3"
<cut>

to:
<cut>
crash> ps -l
...
[             0] [RU]  PID: 0      TASK: ffffffff818d5440  CPU: 0   COMMAND: "swapper/0"
[             0] [RU]  PID: 0      TASK: ffff88003dad4fa0  CPU: 1   COMMAND: "swapper/1"
[             0] [RU]  PID: 0      TASK: ffff88003dad5b00  CPU: 2   COMMAND: "swapper/2" <OFFLINE>
[             0] [RU]  PID: 0      TASK: ffff88003dad6660  CPU: 3   COMMAND: "swapper/3"
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
---
 task.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/task.c b/task.c
index 27c3aa4..2c8c4e4 100755
--- a/task.c
+++ b/task.c
@@ -6609,10 +6609,16 @@ print_task_header(FILE *out, struct task_context *tc, int newline)
 	char buf[BUFSIZE];
 	char buf1[BUFSIZE];
 
-        fprintf(out, "%sPID: %-5ld  TASK: %s  CPU: %-2s  COMMAND: \"%s\"\n",
+	int task_offline;
+
+	task_offline = is_task_active(tc->task) &&
+			check_offline_cpu(tc->processor);
+
+        fprintf(out, "%sPID: %-5ld  TASK: %s  CPU: %-2s  COMMAND: \"%s\" %s\n",
 		newline ? "\n" : "", tc->pid, 
 		mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, MKSTR(tc->task)),
-		task_cpu(tc->processor, buf, !VERBOSE), tc->comm);
+		task_cpu(tc->processor, buf, !VERBOSE), tc->comm,
+		task_offline ? "<OFFLINE>" : "");
 }
 
 /*
-- 
1.8.5.3




More information about the Crash-utility mailing list