From 4ca96fe2948ef5697a691ad10eb57262044e3bd0 Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Fri, 3 Oct 2014 11:38:25 +0800 Subject: [PATCH v3 21/21] modify ps to indicate swapper task on offline cpu this patch will make ps command display "-" preceding the information of swapper task on offline cpu, instead of ">". The original output is like below: PID PPID CPU TASK ST %MEM VSZ RSS COMM > 0 0 0 ffffffff818d5440 RU 0.0 0 0 [swapper/0] > 0 0 1 ffff88003dad4fa0 RU 0.0 0 0 [swapper/1] > 0 0 2 ffff88003dad5b00 RU 0.0 0 0 [swapper/2] > 0 0 3 ffff88003dad6660 RU 0.0 0 0 [swapper/3] 1 0 1 ffff88003da98000 IN 0.7 50792 7056 systemd 2 0 3 ffff88003da98b60 IN 0.0 0 0 [kthreadd] ... With crash variable "offline" set to "hide", the output will be like below: PID PPID CPU TASK ST %MEM VSZ RSS COMM > 0 0 0 ffffffff818d5440 RU 0.0 0 0 [swapper/0] > 0 0 1 ffff88003dad4fa0 RU 0.0 0 0 [swapper/1] - 0 0 2 ffff88003dad5b00 RU 0.0 0 0 [swapper/2] > 0 0 3 ffff88003dad6660 RU 0.0 0 0 [swapper/3] 1 0 1 ffff88003da98000 IN 0.7 50792 7056 systemd 2 0 3 ffff88003da98b60 IN 0.0 0 0 [kthreadd] ... Signed-off-by: Qiao Nuohan --- help.c | 4 +++- task.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/help.c b/help.c index a6f834d..ad42dbf 100755 --- a/help.c +++ b/help.c @@ -1267,7 +1267,9 @@ char *help_ps[] = { " -s replace the TASK column with the KSTACKP column.", " ", " On SMP machines, the active task on each CPU will be highlighted by an", -" angle bracket (\">\") preceding its information.", +" angle bracket (\">\") preceding its information. And If the crash variable", +" \"offline\" is \"hide\", the active task on offline CPU will be highlighted", +" by \"-\"", " ", " Alternatively, information regarding parent-child relationships,", " per-task time usage data, argument/environment data, thread groups,", diff --git a/task.c b/task.c index b8ff658..d52d424 100755 --- a/task.c +++ b/task.c @@ -3093,6 +3093,7 @@ show_ps_data(ulong flag, struct task_context *tc, struct psinfo *psi) char buf2[BUFSIZE]; char buf3[BUFSIZE]; ulong tgid; + int task_active; if ((flag & PS_USER) && is_kernel_thread(tc->task)) return; @@ -3153,7 +3154,17 @@ show_ps_data(ulong flag, struct task_context *tc, struct psinfo *psi) tm = &task_mem_usage; get_task_mem_usage(tc->task, tm); - fprintf(fp, "%s", is_task_active(tc->task) ? "> " : " "); + + task_active = is_task_active(tc->task); + + if (task_active) { + if (hide_offline_cpu(tc->processor)) + fprintf(fp, "- "); + else + fprintf(fp, "> "); + } else + fprintf(fp, " "); + fprintf(fp, "%5ld %5ld %2s %s %3s", tc->pid, task_to_pid(tc->ptask), task_cpu(tc->processor, buf2, !VERBOSE), -- 1.8.5.3