From de13eb846a997ebf3dcc428829116e777808ebdc Mon Sep 17 00:00:00 2001
From: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Date: Sat, 23 Aug 2014 10:21:15 +0800
Subject: [PATCH 04/23] x86_64: modify mach only to display online cpu's data

mach will display number of cpus and cpus' irq stacks and exception
stacks. This patch will ignore offline cpus.

Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
---
 x86_64.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/x86_64.c b/x86_64.c
index 439e447..33045c9 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -5069,7 +5069,7 @@ 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\n", get_cpus_to_display());
 	if (!STREQ(kt->hypervisor, "(undetermined)") &&
 	    !STREQ(kt->hypervisor, "bare hardware"))
 		fprintf(fp, "            HYPERVISOR: %s\n",  kt->hypervisor);
@@ -5092,6 +5092,8 @@ x86_64_display_machine_stats(void)
 	fprintf(fp, "        IRQ STACK SIZE: %d\n", machdep->machspec->stkinfo.isize);
 	fprintf(fp, "            IRQ STACKS:\n");
 	for (c = 0; c < kt->cpus; c++) {
+		if (check_offline_cpu(c))
+			continue;
 		sprintf(buf, "CPU %d", c);
 		fprintf(fp, "%22s: %016lx\n", 
 			buf, machdep->machspec->stkinfo.ibase[c]);
@@ -5108,6 +5110,9 @@ x86_64_display_machine_stats(void)
 		for (c = 0; c < kt->cpus; c++) {
 			if (machdep->machspec->stkinfo.ebase[c][i] == 0)
 				break;
+			if(check_offline_cpu(c))
+				continue;
+
 			sprintf(buf, "CPU %d", c);
 			fprintf(fp, "%22s: %016lx\n", 
 				buf, machdep->machspec->stkinfo.ebase[c][i]);
-- 
1.8.5.3

