this patch will fix ps command not to display ">" before idle task on offline cpu and add an "<OFFLINE>" at the end of the line. The original output is like below: <cut> 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] ... <cut> With this patch, the idle task on offline cpu(cpu #2) will be changed like below: <cut> 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] <OFFLINE> > 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] ... <cut> Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx> --- task.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/task.c b/task.c index 53fc060..27c3aa4 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, task_offline; 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_offline = FALSE; + task_active = is_task_active(tc->task); + + /* check whether the task is "active" on an offline cpu */ + if (task_active && check_offline_cpu(tc->processor)) { + task_active = FALSE; + task_offline = TRUE; + } + + fprintf(fp, "%s", task_active ? "> " : " "); fprintf(fp, "%5ld %5ld %2s %s %3s", tc->pid, task_to_pid(tc->ptask), task_cpu(tc->processor, buf2, !VERBOSE), @@ -3167,9 +3178,14 @@ show_ps_data(ulong flag, struct task_context *tc, struct psinfo *psi) fprintf(fp, "%7ld ", (tm->total_vm * PAGESIZE())/1024); fprintf(fp, "%6ld ", (tm->rss * PAGESIZE())/1024); if (is_kernel_thread(tc->task)) - fprintf(fp, "[%s]\n", tc->comm); + fprintf(fp, "[%s]", tc->comm); else - fprintf(fp, "%s\n", tc->comm); + fprintf(fp, "%s", tc->comm); + + if (task_offline) + fprintf(fp, " <OFFLINE>\n"); + else + fprintf(fp, "\n"); } static void -- 1.8.5.3 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility