ps -l/-m -C cpu is used to dump most-recently run tasks on specified
cpus. This patch is used to hide data of offline cpus.
The original output is like below:
<cut>
crash> ps -l -C 2
CPU: 2
[ 3443744250246] [??] PID: 25 TASK: ffff88003dafb8e0 CPU: 2 COMMAND:
"migration/2"
[ 3443744209862] [??] PID: 24 TASK: ffff88003dafad80 CPU: 2 COMMAND:
"watchdog/2"
...
[ 501159134] [IN] PID: 52 TASK: ffff88003d4a38e0 CPU: 2 COMMAND:
"crypto"
[ 409792745] [IN] PID: 48 TASK: ffff88003d4a4440 CPU: 2 COMMAND:
"kswapd0"
[ 0] [RU] PID: 0 TASK: ffff88003dad5b00 CPU: 2 COMMAND:
"swapper/2"
<cut>
With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> ps -l -C 2
CPU: 2 <OFFLINE>
<cut>
Signed-off-by: Qiao Nuohan <qiaonuohan(a)cn.fujitsu.com>
---
task.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/task.c b/task.c
index 2c8c4e4..bc11cf3 100755
--- a/task.c
+++ b/task.c
@@ -3348,8 +3348,14 @@ show_last_run(struct task_context *tc, struct psinfo *psi)
for (c = others = 0; c < kt->cpus; c++) {
if (!NUM_IN_BITMAP(psi->cpus, c))
continue;
- fprintf(fp, "%sCPU: %d\n",
+ fprintf(fp, "%sCPU: %d",
others++ ? "\n" : "", c);
+ if (hide_offline_cpu(c)) {
+ fprintf(fp, " <OFFLINE>\n");
+ continue;
+ } else
+ fprintf(fp, "\n");
+
tcp = FIRST_CONTEXT();
for (i = 0; i < RUNNING_TASKS(); i++, tcp++) {
if (tcp->processor != c)
@@ -3431,9 +3437,15 @@ show_milliseconds(struct task_context *tc, struct psinfo *psi)
if (!NUM_IN_BITMAP(psi->cpus, c))
continue;
- fprintf(fp, "%sCPU: %d\n",
+ fprintf(fp, "%sCPU: %d",
others++ ? "\n" : "", c);
+ if (hide_offline_cpu(c)) {
+ fprintf(fp, " <OFFLINE>\n");
+ continue;
+ } else
+ fprintf(fp, "\n");
+
if ((kt->flags & SMP) && (kt->flags & PER_CPU_OFF))
runq = rq_sp->value + kt->__per_cpu_offset[c];
else
--
1.8.5.3