[Crash-utility] [PATCH v2 03/25] x86_64: modify help -m/-M to hide offline cpus' data

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


help -m/-M will display current task address/crash nmi rsp/exception
stack/irq stack on x86_64, and these data of offline cpu can be hide
with this patch.

The original display is like below:
<cut>
crash> help -m
...
               current[4]:
   ffffffff818d5440 ffff88003dad4fa0 ffff88003dad5b00 ffff88003dad6660
         crash_nmi_rsp[4]:
   0000000000000000 0000000000000000 0000000000000000 0000000000000000
...
                           ebase[cpus][7]:
   [0]: ffff88003fc04000 ffff88003fc05000 ffff88003fc06000 ffff88003fc07000
        ffff88003fc09000 0000000000000000 0000000000000000
   [1]: ffff88003fc84000 ffff88003fc85000 ffff88003fc86000 ffff88003fc87000
        ffff88003fc89000 0000000000000000 0000000000000000
   [2]: ffff88003fd04000 ffff88003fd05000 ffff88003fd06000 ffff88003fd07000
        ffff88003fd09000 0000000000000000 0000000000000000
   [3]: ffff88003fd84000 ffff88003fd85000 ffff88003fd86000 ffff88003fd87000
        ffff88003fd89000 0000000000000000 0000000000000000
                           ibase[cpus]:
   ffff88003fc00000 ffff88003fc80000 ffff88003fd00000 ffff88003fd80000

<cut>

And with data of offline cpu hiden, the display will be like below:
<cut>
crash> help -m
...
               current[4]:
   ffffffff818d5440 ffff88003dad4fa0     <OFFLINE>    ffff88003dad6660
         crash_nmi_rsp[4]:
   0000000000000000 0000000000000000     <OFFLINE>    0000000000000000
...
                           ebase[cpus][7]:
   [0]: ffff88003fc04000 ffff88003fc05000 ffff88003fc06000 ffff88003fc07000
        ffff88003fc09000 0000000000000000 0000000000000000
   [1]: ffff88003fc84000 ffff88003fc85000 ffff88003fc86000 ffff88003fc87000
        ffff88003fc89000 0000000000000000 0000000000000000
   [2]: <OFFLINE>
   [3]: ffff88003fd84000 ffff88003fd85000 ffff88003fd86000 ffff88003fd87000
        ffff88003fd89000 0000000000000000 0000000000000000
                           ibase[cpus]:
   ffff88003fc00000 ffff88003fc80000     <OFFLINE>    ffff88003fd80000
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
---
 x86_64.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/x86_64.c b/x86_64.c
index a2e4636..9aa6432 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -764,10 +764,16 @@ x86_64_dump_machdep_table(ulong arg)
 	fprintf(fp, "%s            current[%d]:%s", 
 		space(CPU_SPACES(kt->cpus)), kt->cpus,
 		ms->current ? "\n   " : " (unused)\n");
+
 	for (c = 0; ms->current && (c < kt->cpus); c++) { 
 		if (c && !(c%4))
 			fprintf(fp, "\n   ");
-		fprintf(fp, "%016lx ", ms->current[c]);
+
+		if (hide_offline_cpu(c))
+			fprintf(fp, "    <OFFLINE>    ");
+		else
+			fprintf(fp, "%016lx ", ms->current[c]);
+
 	}
 	if (ms->current)
 		fprintf(fp, "\n");
@@ -775,10 +781,15 @@ x86_64_dump_machdep_table(ulong arg)
 	fprintf(fp, "%s      crash_nmi_rsp[%d]:%s", 
 		space(CPU_SPACES(kt->cpus)), kt->cpus, 
 		ms->crash_nmi_rsp ? "\n   " : " (unused)\n");
+
 	for (c = 0; ms->crash_nmi_rsp && (c < kt->cpus); c++) { 
 		if (c && !(c%4))
 			fprintf(fp, "\n   ");
-		fprintf(fp, "%016lx ", ms->crash_nmi_rsp[c]);
+
+		if (hide_offline_cpu(c))
+			fprintf(fp, "    <OFFLINE>    ");
+		else
+			fprintf(fp, "%016lx ", ms->crash_nmi_rsp[c]);
 	}
 	if (ms->crash_nmi_rsp)
 		fprintf(fp, "\n");
@@ -803,6 +814,12 @@ x86_64_dump_machdep_table(ulong arg)
 	cpus = arg ? NR_CPUS : kt->cpus;
 	for (c = 0; c < cpus; c++) {
 		fprintf(fp, "\n  %s[%d]: ", c < 10 ? " " : "", c);
+
+		if (!arg && hide_offline_cpu(c)) {
+			fprintf(fp, "<OFFLINE>");
+			continue;
+		}
+
 		for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { 
 			fprintf(fp, "%016lx ", ms->stkinfo.ebase[c][i]);
 			if (i == 3)
@@ -811,10 +828,16 @@ x86_64_dump_machdep_table(ulong arg)
 	}
 	fprintf(fp, "\n                           ibase[%s]:\n   ",
 		arg ? "NR_CPUS" : "cpus");
+
 	for (c = 0; c < cpus; c++) {
 		if (c && !(c%4))
 			fprintf(fp, "\n   ");
-		fprintf(fp, "%016lx ", ms->stkinfo.ibase[c]);
+
+		if (!arg && hide_offline_cpu(c))
+			fprintf(fp, "    <OFFLINE>    ");
+		else
+			fprintf(fp, "%016lx ", ms->stkinfo.ibase[c]);
+
 	}
 	fprintf(fp, "\n");
 }
-- 
1.8.5.3




More information about the Crash-utility mailing list