[PATCH v3 00/21] support hiding data of offline cpu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For those who don't care about the removed cpu, data of offline cpu is
bothering. This patchset is trying to hide data of offline cpu. Please
check each patch to see what is hiden.

The last version is here:
https://www.redhat.com/archives/crash-utility/2014-September/msg00078.html

Changelog:
v2->v3:
1. change "<OFFLINE>" to "[OFFLINE]" to indicate data of offline cpu
2. delete the following patches:
       x86_64: modify help -m/-M to hide offline cpus' data
       modify help -k to hide offline cpus' number
       modify irq -a to hide offline cpus' data
       modify print_task_header() to indicate idle task on offline cpu

3. change the following patches to remain the original data and append an
   "[OFFLINE]" to indicate the data is related to the offline cpu:
       x86_64: modify mach to hide offline cpus' data
       modify ptov offset:cpuspec to hide offline cpus' data
       modify kmem -o to hide offline cpus' data

4. change output of "modify display_sys_stats() to hide cpus' number"
5. change ps to indicate swapper task on offline cpu with "-"

v1->v2:
1. patch 1: add environment variable and its argument to hide/show
   data of offline cpu.
2. add description of environment variable to crash.8
3. remove the restrict of x86_64
4. add "<OFFLINE>" to indicate those hiden data.
5. patch 22/23: addd "<OFFLINE>" to indicate idle task on offline

Qiao Nuohan (21):
  add a flag to display/hide data of offline cpus
  add an API to check whether to hide a cpus' data
  x86_64: modify bt -E to hide offline cpus' data
  x86_64: modify mach to indicate offline cpus' data
  x86_64: modify mach -c to hide offline cpus' data
  modify help -r to hide offline cpus' registers
  modify bt -c to hide offline cpus' data
  modify display_sys_stats() to indicate offline cpus
  modify set -c to hide offline cpu
  modify irq -s to hide offline cpus' data
  modify timer -r to hide offline cpus' data
  modify timer to hide offline cpus' data
  modify ptov offset:cpuspec to indicate offline cpus' data
  fix max_cpudata_limit() when offlined cpu exists
  modify kmem -o to indicate offline cpus' data
  modify kmem -S(SLUB) to hide offline cpus' data
  modify struct/union/* [:cpuspec] to hide offline cpus' data
  modify command p to hide offline cpus' data
  modify ps -l/-m -C cpu to hide offline cpus' data
  modify runq to hide offline cpus' data
  modify ps to indicate swapper task on offline cpu

 crash.8    |  4 ++++
 defs.h     |  3 +++
 diskdump.c |  6 ++++-
 help.c     | 10 +++++++-
 kernel.c   | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 main.c     | 15 +++++++++++-
 memory.c   | 30 ++++++++++++++++++++----
 netdump.c  | 25 ++++++++++++++++++--
 symbols.c  | 15 +++++++++++-
 task.c     | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 tools.c    | 15 ++++++++++++
 x86_64.c   | 46 ++++++++++++++++++++++++++++++------
 12 files changed, 290 insertions(+), 30 deletions(-)

--
1.8.5.3
From d67eaa5dca792660802dff483f76451be0de1cbb Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Mon, 22 Sep 2014 10:23:08 +0800
Subject: [PATCH v3 01/21] add a flag to display/hide data of offline cpus

Add a field to pc->flags2 to display/hide data related to offline cpu. This
flag can be changed by the following 2 ways:
1. start crash with "--offline [show|hide]"
2. execute crash command "set offline show|hide"

The default set is "show". This flag can be used by later patches to hide
date related to offline cpus. And set can be checked by using command "set -v"

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 crash.8 |  4 ++++
 defs.h  |  1 +
 help.c  |  6 ++++++
 main.c  | 15 ++++++++++++++-
 tools.c | 15 +++++++++++++++
 5 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/crash.8 b/crash.8
index 1223aeb..bebffba 100644
--- a/crash.8
+++ b/crash.8
@@ -503,6 +503,10 @@ determined value.
 .TP
 .BI --kvmio \ <size>
 override the automatically-calculated KVM guest I/O hole size.
+.TP
+.BI --offline \ [show|hide]
+Display/hide data related to offline cpu. Crash command "set offline
+[on|off]" can be used to override the set here.
 .SH COMMANDS
 Each 
 .B crash
diff --git a/defs.h b/defs.h
index cbdaa47..32c9d4d 100755
--- a/defs.h
+++ b/defs.h
@@ -505,6 +505,7 @@ struct program_context {
 #define REM_PAUSED_F (0x1000ULL)
 #define RAMDUMP	(0x2000ULL)
 #define REMOTE_PAUSED() (pc->flags2 & REM_PAUSED_F)
+#define OFFLINE_HIDE (0x4000ULL)
 	char *cleanup;
 	char *namelist_orig;
 	char *namelist_debug_orig;
diff --git a/help.c b/help.c
index 30d7759..a6f834d 100755
--- a/help.c
+++ b/help.c
@@ -339,6 +339,10 @@ char *program_usage_info[] = {
     "  --kvmio <size>",
     "    override the automatically-calculated KVM guest I/O hole size.",
     "",
+    "  --offline [show|hide]",
+    "    Display/hide data related to offline cpu. Crash command \"set offline",
+    "    [show|hide]\" can be used to override the set here",
+    "",
     "FILES:",
     "",
     "  .crashrc",
@@ -1054,6 +1058,8 @@ char *help_set[] = {
 "                               must be a kernel or module text address, which", 
 "                               may be expressed symbolically or as a hexadecimal",
 "                               value.",
+"       offline show | hide     set crash to display or hide data related to",
+"                               offline cpu.",
 " ",
 "  Internal variables may be set in four manners:\n",
 "    1. entering the set command in $HOME/.%src.",
diff --git a/main.c b/main.c
index ad66058..8917f0f 100755
--- a/main.c
+++ b/main.c
@@ -70,6 +70,7 @@ static struct option long_options[] = {
 	{"dec", 0, 0, 0},
 	{"no_strip", 0, 0, 0},
 	{"hash", required_argument, 0, 0},
+	{"offline", required_argument, 0, 0},
         {0, 0, 0, 0}
 };
 
@@ -279,7 +280,17 @@ main(int argc, char **argv)
 				pc->flags2 |= RADIX_OVERRIDE;
 				pc->output_radix = 10;
 			}
-			
+
+			else if (STREQ(long_options[option_index].name, "offline")) {
+				if (STREQ(optarg, "show"))
+					pc->flags2 &= ~OFFLINE_HIDE;
+				else if (STREQ(optarg, "hide"))
+					pc->flags2 |= OFFLINE_HIDE;
+				else {
+					error(INFO, "invalid --offline argument: %s\n", optarg);
+					program_usage(SHORT_FORM);
+				}
+			}
 
 			else {
 				error(INFO, "internal error: option %s unhandled\n",
@@ -1393,6 +1404,8 @@ dump_program_context(void)
 		fprintf(fp, "%sALLOW_FP", others++ ? "|" : "");
 	if (pc->flags2 & RAMDUMP)
 		fprintf(fp, "%sRAMDUMP", others++ ? "|" : "");
+	if (pc->flags2 & OFFLINE_HIDE)
+		fprintf(fp, "%sOFFLINE_HIDE", others++ ? "|" : "");
 	fprintf(fp, ")\n");
 
 	fprintf(fp, "         namelist: %s\n", pc->namelist);
diff --git a/tools.c b/tools.c
index a5f514f..f9c97a4 100755
--- a/tools.c
+++ b/tools.c
@@ -2365,6 +2365,20 @@ cmd_set(void)
 					"on" : "off");
 			return;
 
+                } else if (STREQ(args[optind], "offline")) {
+
+                        if (args[optind+1]) {
+                                optind++;
+                                if (STREQ(args[optind], "show"))
+                                        pc->flags2 &= ~OFFLINE_HIDE;
+                                else if(STREQ(args[optind], "hide"))
+                                        pc->flags2 |= OFFLINE_HIDE;
+                                else
+                                        goto invalid_set_command;
+                        }
+
+			return;
+
 		} else if (XEN_HYPER_MODE()) {
 			error(FATAL, "invalid argument for the Xen hypervisor\n");
 		} else if (pc->flags & MINIMAL_MODE) {
@@ -2467,6 +2481,7 @@ show_options(void)
 		fprintf(fp, "(%s)\n", value_to_symstr(pc->scope, buf, 0));
 	else
 		fprintf(fp, "(not set)\n");
+	fprintf(fp, "       offline: %s\n", pc->flags2 & OFFLINE_HIDE ? "hide" : "show");
 }
 
 
-- 
1.8.5.3

From 309752c6e495cfb47f0e4f48ed7244625010a65d Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Tue, 23 Sep 2014 14:19:32 +0800
Subject: [PATCH v3 02/21] add an API to check whether to hide a cpus' data

check_offline_cpu() is used to check whether a cpu is offline.

hide_offline_cpu() is based on check_offline_cpu() and used to check
whether the data related to the specified cpu should be hiden.
---
 defs.h   |  2 ++
 kernel.c | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/defs.h b/defs.h
index 32c9d4d..0cf4f31 100755
--- a/defs.h
+++ b/defs.h
@@ -4894,6 +4894,8 @@ int get_cpus_online(void);
 int get_cpus_active(void);
 int get_cpus_present(void);
 int get_cpus_possible(void);
+int check_offline_cpu(int);
+int hide_offline_cpu(int);
 int get_highest_cpu_online(void);
 int get_highest_cpu_present(void);
 int get_cpus_to_display(void);
diff --git a/kernel.c b/kernel.c
index 87a0b75..8948c84 100755
--- a/kernel.c
+++ b/kernel.c
@@ -7989,6 +7989,33 @@ get_cpus_online()
 }
 
 /*
+ * check to see whether a cpu is offline
+ */
+int
+check_offline_cpu(int cpu)
+{
+	if (!cpu_map_addr("online"))
+		return FALSE;
+
+	if (in_cpu_map(ONLINE_MAP, cpu))
+		return FALSE;
+
+	return TRUE;
+}
+
+/*
+ * check to see whether the data related to the specified cpu should be hide
+ */
+int
+hide_offline_cpu(int cpu)
+{
+	if (!(pc->flags2 & OFFLINE_HIDE))
+		return FALSE;
+
+	return check_offline_cpu(cpu);
+}
+
+/*
  *  If it exists, return the highest cpu number in the cpu_online_map.
  */
 int
-- 
1.8.5.3

From a96591bced3b0166373c03aa47488d7101c066c3 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Sun, 28 Sep 2014 16:36:54 +0800
Subject: [PATCH v3 03/21] x86_64: modify bt -E to hide offline cpus' data

bt -E will search all irq stacks and exception stacks for possible
exception frames. With this patch offline cpus will be hiden.

The original output will be like:
<cut>
crash> bt -E
CPU 0 IRQ STACK:
(none found)

CPU 1 IRQ STACK:
(none found)

CPU 2 IRQ STACK:
(none found)

CPU 3 IRQ STACK:
(none found)
...
CPU 2 STACKFAULT EXCEPTION STACK:
(none found)

CPU 2 DOUBLEFAULT EXCEPTION STACK:
(none found)

CPU 2 NMI EXCEPTION STACK:
(none found)

CPU 2 DEBUG EXCEPTION STACK:
(none found)

CPU 2 MCE EXCEPTION STACK:
(none found)
...
<cut>

With data of offline cpu hiden, the output is like:
<cut>
crash> bt -E
CPU 0 IRQ STACK:
(none found)

CPU 1 IRQ STACK:
(none found)

CPU 2 IRQ STACK: <OFFLINE>

CPU 3 IRQ STACK:
(none found)
...
CPU 2 STACKFAULT EXCEPTION STACK: <OFFLINE>

CPU 2 DOUBLEFAULT EXCEPTION STACK: <OFFLINE>

CPU 2 NMI EXCEPTION STACK: <OFFLINE>

CPU 2 DEBUG EXCEPTION STACK: <OFFLINE>

CPU 2 MCE EXCEPTION STACK: <OFFLINE>
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 x86_64.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/x86_64.c b/x86_64.c
index a2e4636..a076b02 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -2325,7 +2325,14 @@ x86_64_eframe_search(struct bt_info *bt)
                 	if (ms->stkinfo.ibase[c] == 0)
                         	break;
                                 bt->hp->esp = ms->stkinfo.ibase[c];
-                                fprintf(fp, "CPU %d IRQ STACK:\n", c);
+                                fprintf(fp, "CPU %d IRQ STACK:", c);
+
+				if (hide_offline_cpu(c)) {
+					fprintf(fp, " [OFFLINE]\n\n");
+					continue;
+				} else
+					fprintf(fp, "\n");
+
                                 if ((cnt = x86_64_eframe_search(bt)))
 					fprintf(fp, "\n");
 				else
@@ -2337,8 +2344,15 @@ x86_64_eframe_search(struct bt_info *bt)
                         	if (ms->stkinfo.ebase[c][i] == 0)
                                 	break;
                                 bt->hp->esp = ms->stkinfo.ebase[c][i];
-                                fprintf(fp, "CPU %d %s EXCEPTION STACK:\n", 
+                                fprintf(fp, "CPU %d %s EXCEPTION STACK:",
 					c, x86_64_exception_stacks[i]);
+
+				if (hide_offline_cpu(c)) {
+					fprintf(fp, " [OFFLINE]\n\n");
+					continue;
+				} else
+					fprintf(fp, "\n");
+
                                 if ((cnt = x86_64_eframe_search(bt)))
 					fprintf(fp, "\n");
 				else
-- 
1.8.5.3

From 2ea64d2e3af46b32a17382252d3976e978175baf Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2014 10:17:35 +0800
Subject: [PATCH v3 04/21] x86_64: modify mach to indicate offline cpus' data

mach will display number of cpus and cpus' irq stacks and exception
stacks. This patch can indicate data of offline cpus.

The original output is like below:
<cut>
crash> mach
          MACHINE TYPE: x86_64
           MEMORY SIZE: 1 GB
                  CPUS: 4
...
            IRQ STACKS:
                 CPU 0: ffff88003fc00000
                 CPU 1: ffff88003fc80000
                 CPU 2: ffff88003fd00000
                 CPU 3: ffff88003fd80000
 STACKFAULT STACK SIZE: 4096
     STACKFAULT STACKS:
                 CPU 0: ffff88003fc04000
                 CPU 1: ffff88003fc84000
                 CPU 2: ffff88003fd04000
                 CPU 3: ffff88003fd84000
...
<cut>

With crash variable offline set to "hide", the output is like below:
<cut>
crash> mach
          MACHINE TYPE: x86_64
           MEMORY SIZE: 1 GB
                  CPUS: 4 [1 OFFLINE]
...
            IRQ STACKS:
                 CPU 0: ffff88003fc00000
                 CPU 1: ffff88003fc80000
                 CPU 2: ffff88003fd00000 <OFFLINE>
                 CPU 3: ffff88003fd80000
 STACKFAULT STACK SIZE: 4096
     STACKFAULT STACKS:
                 CPU 0: ffff88003fc04000
                 CPU 1: ffff88003fc84000
                 CPU 2: ffff88003fd04000 <OFFLINE>
                 CPU 3: ffff88003fd84000
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 x86_64.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/x86_64.c b/x86_64.c
index a076b02..9ff57d6 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -5047,7 +5047,8 @@ x86_64_display_machine_stats(void)
 
 	fprintf(fp, "          MACHINE TYPE: %s\n", uts->machine);
 	fprintf(fp, "           MEMORY SIZE: %s\n", get_memory_size(buf));
-	fprintf(fp, "                  CPUS: %d\n", kt->cpus);
+	fprintf(fp, "                  CPUS: %d [%d OFFLINE]\n", kt->cpus,
+		kt->cpus - get_cpus_to_display());
 	if (!STREQ(kt->hypervisor, "(undetermined)") &&
 	    !STREQ(kt->hypervisor, "bare hardware"))
 		fprintf(fp, "            HYPERVISOR: %s\n",  kt->hypervisor);
@@ -5071,8 +5072,14 @@ x86_64_display_machine_stats(void)
 	fprintf(fp, "            IRQ STACKS:\n");
 	for (c = 0; c < kt->cpus; c++) {
 		sprintf(buf, "CPU %d", c);
-		fprintf(fp, "%22s: %016lx\n", 
+		
+		fprintf(fp, "%22s: %016lx",
 			buf, machdep->machspec->stkinfo.ibase[c]);
+
+		if (hide_offline_cpu(c))
+			fprintf(fp, " [OFFLINE]\n");
+		else
+			fprintf(fp, "\n");
 	}
 
 	for (i = 0; i < MAX_EXCEPTION_STACKS; i++) {
@@ -5087,8 +5094,14 @@ x86_64_display_machine_stats(void)
 			if (machdep->machspec->stkinfo.ebase[c][i] == 0)
 				break;
 			sprintf(buf, "CPU %d", c);
-			fprintf(fp, "%22s: %016lx\n", 
+
+			fprintf(fp, "%22s: %016lx",
 				buf, machdep->machspec->stkinfo.ebase[c][i]);
+
+			if (hide_offline_cpu(c))
+				fprintf(fp, " [OFFLINE]\n");
+			else
+				fprintf(fp, "\n");
 		}
 	}
 }
-- 
1.8.5.3

From ca861830879d3b9e3428d690b6fb502bedf80d16 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Tue, 23 Sep 2014 10:54:22 +0800
Subject: [PATCH v3 05/21] x86_64: modify mach -c to hide offline cpus' data

mach -c will display some per-cpu structures. This patch will hide
offline cpus' structures.

The original output is like below:
<cut>
crash> mach -c
...
  cpu_index = 1,
  microcode = 1
}

CPU 2:
struct cpuinfo_x86 {
  x86 = 6 '\006',
  x86_vendor = 0 '\000',
  x86_model = 2 '\002',
  x86_mask = 3 '\003',
  x86_tlbsize = 0,
  x86_virt_bits = 48 '0',
  x86_phys_bits = 40 '(',
...
<cut>

With crash varialbe offline set to "hide", the output is like below:
<cut>
crash> mach -c
...
  cpu_index = 1,
  microcode = 1
}

CPU 2: [OFFLINE]

CPU 3:
struct cpuinfo_x86 {
struct cpuinfo_x86 {
  x86 = 6 '\006',
  x86_vendor = 0 '\000',
  x86_model = 2 '\002',
  x86_mask = 3 '\003',
  x86_tlbsize = 0,
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 x86_64.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/x86_64.c b/x86_64.c
index 9ff57d6..bd2a3e0 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -5145,8 +5145,13 @@ x86_64_display_cpu_data(unsigned int radix)
         for (cpu = 0; cpu < cpus; cpu++) {
 		if (boot_cpu)
                 	fprintf(fp, "BOOT CPU:\n");
-		else
-                	fprintf(fp, "%sCPU %d:\n", cpu ? "\n" : "", cpu);
+		else {
+			if (hide_offline_cpu(cpu)) {
+				fprintf(fp, "%sCPU %d: [OFFLINE]\n", cpu ? "\n" : "", cpu);
+				continue;
+			} else
+				fprintf(fp, "%sCPU %d:\n", cpu ? "\n" : "", cpu);
+		}
 
 		if (per_cpu)
 			cpu_data = per_cpu->value + kt->__per_cpu_offset[cpu];
-- 
1.8.5.3

From 08d71ea4baaf082b22f1385e3fe6a787d2873583 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Tue, 23 Sep 2014 15:54:45 +0800
Subject: [PATCH v3 06/21] modify help -r to hide offline cpus' registers

help -r can display registers on three types of vmcore:
1. qemu memoly-only dump
2. kdump(kdump-compressed format)
3. kdump(elf format)

This patch will hide the offline cpus' registers.

With offline cpus' registers hiden, the output is like below

1. qemu memory-only dump, cpu#1 and cpu#2 are offline
<cut>
...
  idt:
    selector:00000000  limit:00000fff  flags:00000000
    pad:00000000  base:ffffffffff529000
  cr[0]:000000008005003b  cr[1]:0000000000000000  cr[2]:00007f6885fa3000
  cr[3]:000000003b481000  cr[4]:00000000000006f0

CPU 1: [OFFLINE]

CPU 2: [OFFLINE]

CPU 3:
  rax:00000000ffffffed  rbx:ffff88003daeffd8  rcx:0100000000000000
  rdx:0000000000000000  rsi:0000000000000000  rdi:0000000000000046
  rsp:ffff88003daefe98  rbp:ffff88003daefe98   r8:0000000000000000
   r9:0000000000000000  r10:0000000000000013  r11:ffff88003db45028
  r12:0000000000000003  r13:ffff88003daeffd8  r14:0000000000000000
  r15:ffff88003daeffd8  rip:ffffffff81046346  rflags:00000286
...
<cut>

2. kdump(kdump-compressed format), cpu#2 is offline
<cut>
...
CPU 1:
    RIP: ffffffff8134b6c6  RSP: ffff88003df25e18  RFLAGS: 00010096
    RAX: 0000000000000010  RBX: 0000000000000063  RCX: 0000000000000000
    RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000063
    RBP: ffff88003df25e18   R8: 0000000000000000   R9: ffffffff81645da0
    R10: 0000000000000001  R11: 0000000000000000  R12: 0000000000000000
    R13: ffffffff81b01a40  R14: 0000000000000286  R15: 0000000000000004
    CS: 0010  SS: 0018

CPU 2: [OFFLINE]

CPU 3:
    RIP: ffffffff81015670  RSP: ffff88003f3fdca0  RFLAGS: 00000097
    RAX: 0000000000000000  RBX: 000000000000001f  RCX: 0000000000000000
    RDX: 00000000000003d5  RSI: 000000000000001f  RDI: ffffffff81fdd2a8
...
<cut>

3. kdump(elf format), cpu #1 is offline
<cut>
...
    RBP: ffffffff818c3e98   R8: 0000000000000000   R9: 0000000000000000
    R10: 0000000000000000  R11: 0000000000000000  R12: 0000000000000000
    R13: ffffffff818c3fd8  R14: ffff88003ff54780  R15: ffffffff818c3fd8
    CS: 0010  SS: 0018

CPU 1: [OFFLINE]

CPU 2:
    RIP: ffffffff81046346  RSP: ffff88003daede98  RFLAGS: 00000286
    RAX: 00000000ffffffed  RBX: ffff88003daedfd8  RCX: 0100000000000000
    RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000046
    RBP: ffff88003daede98   R8: 0000000000000000   R9: 0000000000000000
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 diskdump.c |  6 +++++-
 netdump.c  | 25 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/diskdump.c b/diskdump.c
index 7639e32..3938552 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2057,7 +2057,11 @@ dump_registers_for_compressed_kdump(void)
 		error(FATAL, "-r option not supported for this dumpfile\n");
 
 	for (c = 0; c < kt->cpus; c++) {
-		fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
+		if (hide_offline_cpu(c)) {
+			fprintf(fp, "%sCPU %d: [OFFLINE]\n", c ? "\n" : "", c);
+			continue;
+		} else
+			fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
 		diskdump_display_regs(c, fp);
 	}
 }
diff --git a/netdump.c b/netdump.c
index e946b45..35e4e69 100644
--- a/netdump.c
+++ b/netdump.c
@@ -2380,8 +2380,19 @@ display_regs_from_elf_notes(int cpu)
 	Elf64_Nhdr *note64;
 	size_t len;
 	char *user_regs;
+	int c, skipped_count;
 
-	if (cpu >= nd->num_prstatus_notes) {
+	/*
+	 * NT_PRSTATUS notes are only related to online cpus, offline cpus
+	 * should be skipped.
+	 */
+	skipped_count = 0;
+	for (c = 0; c < cpu; c++) {
+		if (check_offline_cpu(c))
+			skipped_count++;
+	}
+
+	if ((cpu - skipped_count) >= nd->num_prstatus_notes) {
 		error(INFO, "registers not collected for cpu %d\n", cpu);
 		return;
 	}
@@ -2488,6 +2499,11 @@ dump_registers_for_elf_dumpfiles(void)
 	}
 
         for (c = 0; c < kt->cpus; c++) {
+		if (check_offline_cpu(c)) {
+			fprintf(fp, "%sCPU %d: [OFFLINE]\n", c ? "\n" : "", c);
+			continue;
+		}
+
                 fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
                 display_regs_from_elf_notes(c);
         }
@@ -3786,7 +3802,12 @@ dump_registers_for_qemu_mem_dump(void)
 
 		if (i)
 			netdump_print("\n");
-		netdump_print("CPU %d:\n", i);
+
+		if (hide_offline_cpu(i)) {
+			netdump_print("CPU %d: [OFFLINE]\n", i);
+			continue;
+		} else
+			netdump_print("CPU %d:\n", i);
 
 		if (CRASHDEBUG(1))
 			netdump_print("  version:%08lx      size:%08lx\n",
-- 
1.8.5.3

From 3175fabcc7110c19bfbc36445627a9e10b56f48e Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Tue, 23 Sep 2014 16:42:22 +0800
Subject: [PATCH v3 07/21] modify bt -c to hide offline cpus' data

bt -c will display the stack trace of the active task on specified cpus.
This patch will hide offline cpus' data and print a message like "bt:
CPU xx is offline" to indicate the hide(xx is the id of the offline cpu).

The original output is like below:
<cut>
crash> bt -c 2,3
PID: 0      TASK: ffff88003f380040  CPU: 2   COMMAND: "swapper"
 #0 [ffff88003f3adf00] cpu_idle at ffffffff8100a00b

PID: 22     TASK: ffff88003f3fb500  CPU: 3   COMMAND: "events/3"
 #0 [ffff880002387e90] crash_nmi_callback at ffffffff8102fee6
 #1 [ffff880002387ea0] notifier_call_chain at ffffffff8152d515
 #2 [ffff880002387ee0] atomic_notifier_call_chain at ffffffff8152d57a
 #3 [ffff880002387ef0] notify_die at ffffffff810a154e
 #4 [ffff880002387f20] do_nmi at ffffffff8152b1db
 #5 [ffff880002387f50] nmi at ffffffff8152aaa0
...
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> bt -c 2,3
bt: CPU 2 is OFFLINE.

PID: 22     TASK: ffff88003f3fb500  CPU: 3   COMMAND: "events/3"
 #0 [ffff880002387e90] crash_nmi_callback at ffffffff8102fee6
 #1 [ffff880002387ea0] notifier_call_chain at ffffffff8152d515
 #2 [ffff880002387ee0] atomic_notifier_call_chain at ffffffff8152d57a
 #3 [ffff880002387ef0] notify_die at ffffffff810a154e
 #4 [ffff880002387f20] do_nmi at ffffffff8152b1db
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel.c b/kernel.c
index 8948c84..f5f98ca 100755
--- a/kernel.c
+++ b/kernel.c
@@ -2261,6 +2261,12 @@ cmd_bt(void)
 
 		for (i = 0; i < kt->cpus; i++) {
 			if (NUM_IN_BITMAP(cpus, i)) {
+				if (hide_offline_cpu(i)) {
+					error(INFO, "%sCPU %d is OFFLINE.\n",
+					      subsequent++ ? "\n" : "", i);
+					continue;
+				}
+
 				if ((task = get_active_task(i)))
 					tc = task_to_context(task);
 				else
-- 
1.8.5.3

From 94ce970f126c45b00f6215dd657df19f6cf1c593 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2014 10:35:25 +0800
Subject: [PATCH v3 08/21] modify display_sys_stats() to indicate offline cpus

function display_sys_stats will display the cpus' total number at initiation
when crash is executed or when command sys is called. With this patch, offline
cpus's total number will also be displayed.

The has 4 cpus and cpu#2 is offline. The original display is like below:
<cut>
      KERNEL: ../kdump/vmlinux
    DUMPFILE: ../kdump/vmcore  [PARTIAL DUMP]
        CPUS: 4
        DATE: Tue Sep 23 14:54:26 2014
      UPTIME: 00:02:45
...
<cut>

With this patch, the output is like below:
<cut>
      KERNEL: ../kdump/vmlinux
    DUMPFILE: ../kdump/vmcore  [PARTIAL DUMP]
        CPUS: 4 [1 OFFLINE]
        DATE: Tue Sep 23 14:54:26 2014
      UPTIME: 00:02:45
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel.c b/kernel.c
index f5f98ca..90e6f79 100755
--- a/kernel.c
+++ b/kernel.c
@@ -4796,8 +4796,11 @@ display_sys_stats(void)
 				pc->kvmdump_mapfile);
 	}
 	
-	fprintf(fp, "        CPUS: %d\n",
-		machine_type("PPC64") ? get_cpus_to_display() : kt->cpus);
+	if (machine_type("PPC64"))
+		fprintf(fp, "        CPUS: %d\n", get_cpus_to_display());
+	else
+		fprintf(fp, "        CPUS: %d [%d OFFLINE]\n", kt->cpus,
+			kt->cpus - get_cpus_to_display());
 	if (ACTIVE())
 		get_xtime(&kt->date);
         fprintf(fp, "        DATE: %s\n", 
-- 
1.8.5.3

From 7a45a4e7d035c384d84050e5446f2813986e31c1 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Wed, 24 Sep 2014 11:38:25 +0800
Subject: [PATCH v3 09/21] modify set -c to hide offline cpu

With this patch and crash variable "offline" is hide(check command "set -v"),
"set -c" is not able to set to an offline cpu and message like below will be
printed.

<cut>
crash> set -c 2
set invalid cpu number: cpu 2 is OFFLINE
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel.c b/kernel.c
index 90e6f79..6dd6daf 100755
--- a/kernel.c
+++ b/kernel.c
@@ -5486,6 +5486,10 @@ set_cpu(int cpu)
 	if (cpu >= kt->cpus)
 		error(FATAL, "invalid cpu number: system has only %d cpu%s\n", 
 			kt->cpus, kt->cpus > 1 ? "s" : "");
+
+	if (hide_offline_cpu(cpu))
+		error(FATAL, "invalid cpu number: cpu %d is OFFLINE\n", cpu);
+
 	if ((task = get_active_task(cpu))) 
 		set_context(task, NO_PID);
 	else
-- 
1.8.5.3

From a238e38e8117bf9da221dec40a588bdebef0f5e9 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Wed, 24 Sep 2014 14:53:31 +0800
Subject: [PATCH v3 10/21] modify irq -s to hide offline cpus' data

irq -s will display kernel irq stats. This patch will hide data of
offline cpus

The original output is like below:
<cut>
crash> irq -s
           CPU0       CPU1       CPU2       CPU3
  0:        111          1          0          0  IO-APIC-edge     timer
  1:         71        149        140        155  IO-APIC-edge     i8042
  8:          0          0          0          1  IO-APIC-edge     rtc0
  9:          0          0          0          0  IO-APIC-fasteoi  acpi
...
<cut>

With data of offline cpu(cpu#2) hiden, the output is like below:
<cut>
crash> irq -s
irq: CPU2 is OFFLINE.
           CPU0       CPU1       CPU3
  0:        111          1          0  IO-APIC-edge     timer
  1:         71        149        155  IO-APIC-edge     i8042
  8:          0          0          1  IO-APIC-edge     rtc0
  9:          0          0          0  IO-APIC-fasteoi  acpi
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/kernel.c b/kernel.c
index 6dd6daf..ddf55aa 100755
--- a/kernel.c
+++ b/kernel.c
@@ -5626,9 +5626,18 @@ cmd_irq(void)
 				SET_BIT(cpus, i);
 		}
 
+		for (i = 0; i < kt->cpus; i++) {
+			if (NUM_IN_BITMAP(cpus, i) && hide_offline_cpu(i))
+				error(INFO, "CPU%d is OFFLINE.\n", i);
+		}
+
 		fprintf(fp, "     ");
 		BZERO(buf, 10);
+
 		for (i = 0; i < kt->cpus; i++) {
+			if (hide_offline_cpu(i))
+				continue;
+
 			if (NUM_IN_BITMAP(cpus, i)) {
 				sprintf(buf, "CPU%d", i);
 				fprintf(fp, "%10s ", buf);
@@ -6426,6 +6435,9 @@ generic_show_interrupts(int irq, ulong *cpus)
 	fprintf(fp, "%3d: ", irq);
 
 	for (i = 0; i < kt->cpus; i++) {
+		if (hide_offline_cpu(i))
+			continue;
+
 		if (NUM_IN_BITMAP(cpus, i))
 			fprintf(fp, "%10u ", kstat_irqs[i]);
 	}
-- 
1.8.5.3

From a74f889d9ada5ebe7c86b48f3aa0e3ceb5b9991d Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 10:27:30 +0800
Subject: [PATCH v3 11/21] modify timer -r to hide offline cpus' data

timer -r will display hrtimer. This patch will hide offline cpus.

The original output is like below:
<cut>
crash> timer -r
...
  CLOCK: 2  HRTIMER_CLOCK_BASE: ffff88003fc8e800  [ktime_get_boottime]
  (empty)

CPU: 2  HRTIMER_CPU_BASE: ffff88003fd0e740
  CLOCK: 0  HRTIMER_CLOCK_BASE: ffff88003fd0e780  [ktime_get]
  (empty)

  CLOCK: 1  HRTIMER_CLOCK_BASE: ffff88003fd0e7c0  [ktime_get_real]
  (empty)

  CLOCK: 2  HRTIMER_CLOCK_BASE: ffff88003fd0e800  [ktime_get_boottime]
  (empty)

CPU: 3  HRTIMER_CPU_BASE: ffff88003fd8e740
...
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> timer -r
...
  CLOCK: 2  HRTIMER_CLOCK_BASE: ffff88003fc8e800  [ktime_get_boottime]
  (empty)

CPU: 2  [OFFLINE]

CPU: 3  HRTIMER_CPU_BASE: ffff88003fd8e740
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel.c b/kernel.c
index ddf55aa..377e03c 100755
--- a/kernel.c
+++ b/kernel.c
@@ -6761,9 +6761,16 @@ dump_hrtimer_data(void)
 		option_not_supported('r');
 
 	hrtimer_bases = per_cpu_symbol_search("hrtimer_bases");
+
 	for (i = 0; i < kt->cpus; i++) {
 		if (i)
 			fprintf(fp, "\n");
+
+		if (hide_offline_cpu(i)) {
+			fprintf(fp, "CPU: %d  [OFFLINE]\n", i);
+			continue;
+		}
+
 		fprintf(fp, "CPU: %d  ", i);
 		if (VALID_STRUCT(hrtimer_clock_base)) {
 			fprintf(fp, "HRTIMER_CPU_BASE: %lx\n",
-- 
1.8.5.3

From 20e61c23ff5671a3799a5860210732cee4fefef5 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 15:01:37 +0800
Subject: [PATCH v3 12/21] modify timer to hide offline cpus' data

This patch will hide timer data of offline cpus.

The original output is like below:
<cut>
crash> timer
...
4310933504  ffffffffa0311750  ffffffff8154f790  <inet_frag_secret_rebuild>
4380688384  ffff880036dae568  ffffffff8157ed30  <ipv6_regen_rndid>
TVEC_BASES[2]: ffff88003db20000
JIFFIES
4310640297
EXPIRES     TIMER_LIST         FUNCTION
TVEC_BASES[3]: ffff88003db44000
  JIFFIES
4310640297
...
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> timer
...
4310933504  ffffffffa0311750  ffffffff8154f790  <inet_frag_secret_rebuild>
4380688384  ffff880036dae568  ffffffff8157ed30  <ipv6_regen_rndid>
TVEC_BASES[2]: [OFFLINE]
TVEC_BASES[3]: ffff88003db44000
  JIFFIES
4310640297
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 kernel.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel.c b/kernel.c
index 377e03c..c71748d 100755
--- a/kernel.c
+++ b/kernel.c
@@ -7431,6 +7431,16 @@ dump_timer_data_tvec_bases_v2(void)
 	cpu = 0;
 
 next_cpu:
+	/*
+	 * hide data of offline cpu and goto next cpu
+	 */
+
+	if (hide_offline_cpu(cpu)) {
+	        fprintf(fp, "TVEC_BASES[%d]: [OFFLINE]\n", cpu);
+		if (++cpu < kt->cpus)
+			goto next_cpu;
+	}
+
 
 	count = 0;
 	td = (struct timer_data *)NULL;
-- 
1.8.5.3

From d5bb07dc5f046bfee2b9f8eaa200fe04e1baf754 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2014 11:23:22 +0800
Subject: [PATCH v3 13/21] modify ptov offset:cpuspec to indicate offline cpus'
 data

ptov offset:cpuspec can be used to translate per-cpu offset to kernel
virtual address. This patch will indicate data of offline cpu.

The original output is like below:
<cut>
crash> ptov bfa0:a
PER-CPU OFFSET: bfa0
  CPU    VIRTUAL
  [0]  ffff88003fc0bfa0
  [1]  ffff88003fc8bfa0
  [2]  ffff88003fd0bfa0
  [3]  ffff88003fd8bfa0
<cut>

With crash variable offline set to "hide", the output is like below:
<cut>
crash> ptov bfa0:a
PER-CPU OFFSET: bfa0
  CPU    VIRTUAL
  [0]  ffff88003fc0bfa0
  [1]  ffff88003fc8bfa0
  [2]  ffff88003fd0bfa0 <OFFLINE>
  [3]  ffff88003fd8bfa0
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 memory.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/memory.c b/memory.c
index 518c917..6b64e21 100755
--- a/memory.c
+++ b/memory.c
@@ -3192,9 +3192,14 @@ cmd_ptov(void)
 					continue;
 				vaddr = paddr + kt->__per_cpu_offset[c];
 				sprintf(buf1, "[%d]", c);
-				fprintf(fp, "  %s%lx\n", 
-			    		mkstring(buf2, len, LJUST, buf1),
+				fprintf(fp, "  %s%lx",
+					mkstring(buf2, len, LJUST, buf1),
 					vaddr);
+
+				if (hide_offline_cpu(c))
+					fprintf(fp, " [OFFLINE]\n");
+				else
+					fprintf(fp, "\n");
 			}
 			FREEBUF(cpus);
 		} else {
-- 
1.8.5.3

From 7a5b0d9eb6642b994451c328d748b2e4481d23e0 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 15:35:35 +0800
Subject: [PATCH v3 14/21] fix max_cpudata_limit() when offlined cpu exists

When determining the largest cpudata limit for kmem_cache, the member,
limit, of kmem_cache.array[NR_CPUS] is needed, and the process will
stop when kmem_cache.array[cpu] equals to NULL. However, when offline
cpus exist, kmem_cache.array[cpu] of offline cpus are alse NULL. Then
the process of determining the largest cpudata limit will ignore the
cpus after the offlined cpu.

This patch is used to fix the above problem.

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 memory.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index 6b64e21..c321b77 100755
--- a/memory.c
+++ b/memory.c
@@ -9182,7 +9182,13 @@ kmem_cache_s_array_nodes:
             "array cache array", RETURN_ON_ERROR))
 		goto bail_out;
 
-	for (i = max_limit = 0; (i < kt->cpus) && cpudata[i]; i++) {
+	for (i = max_limit = 0; i < kt->cpus; i++) {
+		if (check_offline_cpu(i))
+			continue;
+
+		if (!cpudata[i])
+			break;
+
                 if (!readmem(cpudata[i]+OFFSET(array_cache_limit),
                     KVADDR, &limit, sizeof(int),
                     "array cache limit", RETURN_ON_ERROR)) {
-- 
1.8.5.3

From 72f372ed3361049a6051442c2bbd8cedea384698 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2014 11:29:03 +0800
Subject: [PATCH v3 15/21] modify kmem -o to indicate offline cpus' data

kmem -o is used to display each cpu's offset value that is added
to per-cpu symbol values to translate them into kernel virtual
addresses. This patch will indicate data of offline cpus.

The original output is like below:
<cut>
crash> kmem -o
PER-CPU OFFSET VALUES:
  CPU 0: ffff88003fc00000
  CPU 1: ffff88003fc80000
  CPU 2: ffff88003fd00000
  CPU 3: ffff88003fd80000
<cut>

With crash variable offline set to "hide", the output is like below:
<cut>
crash> kmem -o
PER-CPU OFFSET VALUES:
  CPU 0: ffff88003fc00000
  CPU 1: ffff88003fc80000
  CPU 2: ffff88003fd00000 [OFFLINE]
  CPU 3: ffff88003fd80000
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 memory.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index c321b77..0d9849b 100755
--- a/memory.c
+++ b/memory.c
@@ -17017,7 +17017,13 @@ dump_per_cpu_offsets(void)
 
 	for (c = 0; c < kt->cpus; c++) {
 		sprintf(buf, "CPU %d", c);
-		fprintf(fp, "%7s: %lx\n", buf, kt->__per_cpu_offset[c]);
+		fprintf(fp, "%7s: %lx", buf, kt->__per_cpu_offset[c]);
+
+		if(hide_offline_cpu(c))
+			fprintf(fp, " [OFFLINE]\n");
+		else
+			fprintf(fp, "\n");
+
 	}
 }
 
-- 
1.8.5.3

From 3bd76b38066acdd78619089544a89eff30f68462 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 16:30:57 +0800
Subject: [PATCH v3 16/21] modify kmem -S(SLUB) to hide offline cpus' data

if SLUB is configured, kmem -S will display per-cpu data. This patch
will hide data of offline cpu.

The original output is like below:
<cut>
crash> kmem -S
...
CPU 1 KMEM_CACHE_CPU:
  ffff88003fc97360
CPU 1 SLAB:
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  ffffea0000dc0d40  ffff880037035000     0     16         11     5
  FREE / [ALLOCATED]
  [ffff880037035000]
  [ffff880037035100]
...
  [ffff88003c6e0f00]
CPU 2 KMEM_CACHE_CPU:
  ffff88003fd17360
CPU 2 SLAB:
  (empty)
CPU 2 PARTIAL:
  (empty)
CPU 3 KMEM_CACHE_CPU:
  ffff88003fd97360
CPU 3 SLAB:
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  ffffea0000ed8f80  ffff88003b63e000     0     16         13     3
  FREE / [ALLOCATED]
  [ffff88003b63e000]
...
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> kmem -S
...
CPU 1 KMEM_CACHE_CPU:
  ffff88003fc97360
CPU 1 SLAB:
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  ffffea0000dc0d40  ffff880037035000     0     16         11     5
  FREE / [ALLOCATED]
  [ffff880037035000]
  [ffff880037035100]
...
  [ffff88003c6e0f00]
CPU 2 [OFFLINE]
CPU 3 KMEM_CACHE_CPU:
  ffff88003fd97360
CPU 3 SLAB:
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  ffffea0000ed8f80  ffff88003b63e000     0     16         13     3
  FREE / [ALLOCATED]
  [ffff88003b63e000]
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 memory.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/memory.c b/memory.c
index 0d9849b..60a789f 100755
--- a/memory.c
+++ b/memory.c
@@ -17468,6 +17468,11 @@ do_kmem_cache_slub(struct meminfo *si)
 	per_cpu = (ulong *)GETBUF(sizeof(ulong) * vt->numnodes);
 
         for (i = 0; i < kt->cpus; i++) {
+		if (hide_offline_cpu(i)) {
+			fprintf(fp, "CPU %d [OFFLINE]\n", i);
+			continue;
+		}
+
 		cpu_slab_ptr = ULONG(si->cache_buf + OFFSET(kmem_cache_cpu_slab)) +
 				kt->__per_cpu_offset[i];
 		fprintf(fp, "CPU %d KMEM_CACHE_CPU:\n  %lx\n", i, cpu_slab_ptr);
-- 
1.8.5.3

From aaf03675a7735624c56030087d5841e7a9ae2ce5 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 16:45:11 +0800
Subject: [PATCH v3 17/21] modify struct/union/* [:cpuspec] to hide offline
 cpus' data

with [:cpuspec] struct/union/* will display per-cpu structure/union of the
specified cpus. This patch will hide data of offline cpus.

The original output is like below:
<cut>
crash> call_function_data 15080:a
[0]: ffff88003fc15080
struct call_function_data {
  csd = 0x177e8,
...
  cpumask = 0xffff88003daf4000,
  cpumask_ipi = 0xffff88003daf4400
}
[2]: ffff88003fd15080
struct call_function_data {
  csd = 0x18248,
  cpumask = 0xffff88003daf4800,
  cpumask_ipi = 0xffff88003daf4c00
}
[3]: ffff88003fd95080
...
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> call_function_data 15080:a
[0]: ffff88003fc15080
struct call_function_data {
  csd = 0x177e8,
...
  cpumask = 0xffff88003daf4000,
  cpumask_ipi = 0xffff88003daf4400
}
[2]: [OFFLINE]
[3]: ffff88003fd95080
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 symbols.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/symbols.c b/symbols.c
index a0f256e..c5c760f 100755
--- a/symbols.c
+++ b/symbols.c
@@ -6147,7 +6147,15 @@ cmd_datatype_common(ulong flags)
 				continue;
 
 			cpuaddr = addr + kt->__per_cpu_offset[c];
-			fprintf(fp, "[%d]: %lx\n", c, cpuaddr);
+
+			fprintf(fp, "[%d]: ", c);
+
+			if (hide_offline_cpu(c)) {
+				fprintf(fp, "[OFFLINE]\n");
+				continue;
+			}
+
+			fprintf(fp, "%lx\n", cpuaddr);
 			do_datatype_addr(dm, cpuaddr , count,
 					 flags, memberlist, argc_members);
 		}
-- 
1.8.5.3

From 62e33a19d02bbecf8838911be473f395d9fbd548 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2014 17:22:36 +0800
Subject: [PATCH v3 18/21] modify command p to hide offline cpus' data

command p can be used to display data of per-cpu symbol. This patch is
used to hide data of offline cpus.

The original output is like below:
<cut>
crash> p cpu_number:a
per_cpu(cpu_number, 0) = $1 = 0
per_cpu(cpu_number, 1) = $2 = 1
per_cpu(cpu_number, 2) = $3 = 2
per_cpu(cpu_number, 3) = $4 = 3
<cut>

With data of offline cpu(cpu #2) hiden, the output is like below:
<cut>
crash> p cpu_number:a
per_cpu(cpu_number, 0) = $1 = 0
per_cpu(cpu_number, 1) = $2 = 1
cpu 2 is OFFLINE.
per_cpu(cpu_number, 3) = $3 = 3
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 symbols.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/symbols.c b/symbols.c
index c5c760f..8aee32a 100755
--- a/symbols.c
+++ b/symbols.c
@@ -6847,6 +6847,11 @@ display_per_cpu_info(struct syment *sp, int radix, char *cpuspec)
 		module_symbol(sp->value, NULL, NULL, NULL, *gdb_output_radix);
 
 	for (c = 0; c < kt->cpus; c++) {
+		if (hide_offline_cpu(c)) {
+			fprintf(fp, "cpu %d is OFFLINE.\n", c);
+			continue;
+		}
+
 		if (cpus && !NUM_IN_BITMAP(cpus, c))
 			continue;
 		addr = sp->value + kt->__per_cpu_offset[c];
-- 
1.8.5.3

From 3aacee0f369acbef16743746c1314910bbc3cd62 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Sat, 27 Sep 2014 15:04:22 +0800
Subject: [PATCH v3 19/21] modify ps -l/-m -C cpu to hide offline cpus' data

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@xxxxxxxxxxxxxx>
---
 task.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/task.c b/task.c
index 53fc060..86be744 100755
--- a/task.c
+++ b/task.c
@@ -3332,8 +3332,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)
@@ -3415,9 +3421,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

From 7bc0b00bd90f5ae1bb8baa22027277817350c656 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
Date: Sun, 28 Sep 2014 16:22:26 +0800
Subject: [PATCH v3 20/21] modify runq to hide offline cpus' data

With the patch, runq [-t/-m/-g/-d] can hide data on offline cpus.

The original output of thest command is like below:
<cut>
crash> runq
CPU 0 RUNQUEUE: ffff88002c216680
  CURRENT: PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
  RT PRIO_ARRAY: ffff88002c216808
     [no tasks queued]
  CFS RB_ROOT: ffff88002c216718
     [no tasks queued]

...
CPU 3 RUNQUEUE: ffff88002c396680
  CURRENT: PID: 0      TASK: ffff880219f9aaa0  COMMAND: "swapper"
  RT PRIO_ARRAY: ffff88002c396808
     [no tasks queued]
  CFS RB_ROOT: ffff88002c396718
     [no tasks queued]
crash> runq -t
 CPU 0: 107470918732460
        000000000000000  PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
 CPU 1: 107470922094506
        000000000000000  PID: 0      TASK: ffff880219f5b540  COMMAND: "swapper"
 CPU 2: 107470921985118
        107470921000315  PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"
 CPU 3: 15082503595357
        00000000000000  PID: 0      TASK: ffff880219f9aaa0  COMMAND: "swapper"
crash> runq -m
 CPU 0: [1 05:51:25.919]  PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
 CPU 1: [0 00:00:00.002]  PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"
 CPU 2: [1 05:51:25.911]  PID: 0      TASK: ffff880219f64040  COMMAND: "swapper"
 CPU 3: [0 04:11:22.503]  PID: 0      TASK: ffff880219f9aaa0  COMMAND: "swapper"
crash> runq -g
CPU 0
  CURRENT: PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
  INIT_TASK_GROUP: ffffffff81e1f780  RT_RQ: ffff88002c216808
     [no tasks queued]
  INIT_TASK_GROUP: ffffffff81e1f780  CFS_RQ: ffff88002c2166e8
     [no tasks queued]

...
CPU 3
  CURRENT: PID: 0      TASK: ffff880219f9aaa0  COMMAND: "swapper"
  INIT_TASK_GROUP: ffffffff81e1f780  RT_RQ: ffff88002c396808
     [no tasks queued]
  INIT_TASK_GROUP: ffffffff81e1f780  CFS_RQ: ffff88002c3966e8
     [no tasks queued]
crash> runq -d
CPU 0
     [no tasks queued]

CPU 1
     [120] PID: 2760   TASK: ffff88021305aaa0  COMMAND: "Xorg"

CPU 2
     [120] PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"

CPU 3
     [no tasks queued]
<cut>

With data of offline cpu(cpu #3) hiden, the output is like below:
<cut>
crash> runq
CPU 0 RUNQUEUE: ffff88002c216680
  CURRENT: PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
  RT PRIO_ARRAY: ffff88002c216808
     [no tasks queued]
  CFS RB_ROOT: ffff88002c216718
     [no tasks queued]

...
CPU 2 RUNQUEUE: ffff88002c316680
  CURRENT: PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"
  RT PRIO_ARRAY: ffff88002c316808
     [no tasks queued]
  CFS RB_ROOT: ffff88002c316718
     [no tasks queued]

CPU 3 [OFFLINE]
crash> runq -t
 CPU 0: 107605503006397
        107605495037692  PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"
 CPU 1: 107605503645955
        000000000000000  PID: 0      TASK: ffff880219f5b540  COMMAND: "swapper"
 CPU 2: 107605500267130
        000000000000000  PID: 0      TASK: ffff880219f64040  COMMAND: "swapper"
 CPU 3: [OFFLINE]
crash> runq -m
 CPU 0: [1 05:53:41.958]  PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
 CPU 1: [1 05:53:41.959]  PID: 0      TASK: ffff880219f5b540  COMMAND: "swapper"
 CPU 2: [0 00:00:00.000]  PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"
 CPU 3: [OFFLINE]
crash> runq -g
CPU 0
  CURRENT: PID: 0      TASK: ffffffff81a8d020  COMMAND: "swapper"
  INIT_TASK_GROUP: ffffffff81e1f780  RT_RQ: ffff88002c216808
     [no tasks queued]
  INIT_TASK_GROUP: ffffffff81e1f780  CFS_RQ: ffff88002c2166e8
     [no tasks queued]

...
CPU 2
  CURRENT: PID: 0      TASK: ffff880219f64040  COMMAND: "swapper"
  INIT_TASK_GROUP: ffffffff81e1f780  RT_RQ: ffff88002c316808
     [no tasks queued]
  INIT_TASK_GROUP: ffffffff81e1f780  CFS_RQ: ffff88002c3166e8
     [no tasks queued]

CPU 3 [OFFLINE]
crash> runq -d
CPU 0
     [no tasks queued]

CPU 1
     [120] PID: 16905  TASK: ffff88018f6e3500  COMMAND: "crash"

CPU 2
     [no tasks queued]

CPU 3 [OFFLINE]
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 task.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/task.c b/task.c
index 86be744..b8ff658 100755
--- a/task.c
+++ b/task.c
@@ -7619,8 +7619,14 @@ dump_on_rq_timestamp(void)
 
                 sprintf(buf, pc->output_radix == 10 ? "%llu" : "%llx",
 			timestamp);
-		fprintf(fp, "%sCPU %d: %s\n", cpu < 10 ? " " : "", 
-			cpu, buf);
+		fprintf(fp, "%sCPU %d: ", cpu < 10 ? " " : "", cpu);
+
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, "[OFFLINE]\n");
+			continue;
+		} else
+			fprintf(fp, "%s\n", buf);
+
 		len = strlen(buf);
 
 		if ((tc = task_to_context(tt->active_set[cpu]))){
@@ -7699,6 +7705,11 @@ dump_on_rq_milliseconds(void)
 		else
 			indent = max_indent - 4;
 
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, "%sCPU %d: [OFFLINE]\n", space(indent), cpu);
+			continue;
+		}
+
 		if ((tc = task_to_context(tt->active_set[cpu])))
 			task_timestamp = task_last_run(tc->task);
 		else { 
@@ -7826,8 +7837,13 @@ dump_runqueues(void)
 				runq = rq_sp->value;
 		}
 
-		fprintf(fp, "%sCPU %d RUNQUEUE: %lx\n", cpu ? "\n" : "", 
-			cpu, runq);
+		fprintf(fp, "%sCPU %d ", cpu ? "\n" : "", cpu);
+
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, "[OFFLINE]\n");
+			continue;
+		} else
+			fprintf(fp, "RUNQUEUE: %lx\n", runq);
 
 		fprintf(fp, "  CURRENT: ");
 		if ((tc = task_to_context(tt->active_set[cpu])))
@@ -8281,8 +8297,13 @@ dump_on_rq_tasks(void)
 	}
 
 	for (cpu = 0; cpu < kt->cpus; cpu++) {
+                fprintf(fp, "%sCPU %d", cpu ? "\n" : "", cpu);
 
-                fprintf(fp, "%sCPU %d\n", cpu ? "\n" : "", cpu);
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, " [OFFLINE]\n");
+			continue;
+		} else
+			fprintf(fp, "\n");
 
 		tc = FIRST_CONTEXT();
 		tot = 0;
@@ -8415,8 +8436,13 @@ dump_CFS_runqueues(void)
 		else
 			runq = rq_sp->value;
 
-                fprintf(fp, "%sCPU %d RUNQUEUE: %lx\n", cpu ? "\n" : "",
-			cpu, runq);
+                fprintf(fp, "%sCPU %d ", cpu ? "\n" : "", cpu);
+
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, "[OFFLINE]\n");
+			continue;
+		} else
+			fprintf(fp, "RUNQUEUE: %lx\n", runq);
 
 		fprintf(fp, "  CURRENT: ");
 		if ((tc = task_to_context(tt->active_set[cpu])))
@@ -8908,7 +8934,14 @@ dump_tasks_by_task_group(void)
 			sizeof(ulong), "task_group rt_rq", FAULT_ON_ERROR);
 		readmem(cfs_rq + cpu * sizeof(ulong), KVADDR, &cfs_rq_p,
 			sizeof(ulong), "task_group cfs_rq", FAULT_ON_ERROR);
-		fprintf(fp, "%sCPU %d\n", cpu ? "\n" : "", cpu);
+		fprintf(fp, "%sCPU %d", cpu ? "\n" : "", cpu);
+
+		if (hide_offline_cpu(cpu)) {
+			fprintf(fp, " [OFFLINE]\n");
+			continue;
+		} else
+			fprintf(fp, "\n");
+
 		fprintf(fp, "  CURRENT: ");
 		if ((tc = task_to_context(tt->active_set[cpu])))
 			fprintf(fp, "PID: %-5ld  TASK: %lx  COMMAND: \"%s\"\n",
-- 
1.8.5.3

From 4ca96fe2948ef5697a691ad10eb57262044e3bd0 Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
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:
<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 crash variable "offline" set to "hide", the output will be 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>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 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

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux