[Crash-utility] [PATCH v2 1/4] crash: change some marcos related to cpu map

Liu Hua sdu.liu at huawei.com
Mon Apr 28 15:15:05 UTC 2014


This patch simply changes there marcos : ONLINE, PRESENT,
POSSIBLE to ONLINE_MAP, PRESENT_MAP and POSSIBLE_MAP.

When I introduce ACTIVE_MAP in next patch, It will make
the code clearer. Because ACTIVE has been defined.

Signed-off-by: Liu Hua <sdu.liu at huawei.com>
---
 defs.h     |  6 +++---
 diskdump.c |  4 ++--
 kernel.c   | 25 +++++++++++++------------
 netdump.c  |  4 ++--
 ppc.c      |  2 +-
 ppc64.c    | 12 ++++++------
 s390.c     |  4 ++--
 s390x.c    |  4 ++--
 8 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/defs.h b/defs.h
index b5cff61..c40cf8d 100644
--- a/defs.h
+++ b/defs.h
@@ -652,9 +652,9 @@ struct kernel_table {                   /* kernel data */
 	long *__rq_idx;
 	long *__cpu_idx;
 	ulong *cpu_flags;
-#define POSSIBLE  (0x1)
-#define PRESENT   (0x2)
-#define ONLINE    (0x4)
+#define POSSIBLE_MAP  (0x1)
+#define PRESENT_MAP   (0x2)
+#define ONLINE_MAP    (0x4)
 #define NMI       (0x8)
 	int BUG_bytes;
 	ulong xen_flags;
diff --git a/diskdump.c b/diskdump.c
index 55ba3ac..8d43840 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -119,7 +119,7 @@ map_cpus_to_prstatus_kdump_cmprs(void)
 	nrcpus = (kt->kernel_NR_CPUS ? kt->kernel_NR_CPUS : NR_CPUS);
 
 	for (i = 0, j = 0; i < nrcpus; i++) {
-		if (in_cpu_map(ONLINE, i)) {
+		if (in_cpu_map(ONLINE_MAP, i)) {
 			dd->nt_prstatus_percpu[i] = nt_ptr[j++];
 			dd->num_prstatus_notes = 
 				MAX(dd->num_prstatus_notes, i+1);
@@ -1202,7 +1202,7 @@ get_diskdump_panic_task(void)
 		if (kernel_symbol_exists("crashing_cpu") &&
 		    cpu_map_addr("online")) {
 			get_symbol_data("crashing_cpu", sizeof(int), &i);
-			if ((i >= 0) && in_cpu_map(ONLINE, i)) {
+			if ((i >= 0) && in_cpu_map(ONLINE_MAP, i)) {
 				if (CRASHDEBUG(1))
 					error(INFO, "get_diskdump_panic_task: "
 					    "active_set[%d]: %lx\n", 
diff --git a/kernel.c b/kernel.c
index 9ed280e..87656fe 100644
--- a/kernel.c
+++ b/kernel.c
@@ -795,9 +795,9 @@ cpu_maps_init(void)
 		ulong cpu_flag;
 		char *name;
 	} mapinfo[] = {
-		{ POSSIBLE, "possible" },
-		{ PRESENT, "present" },
-		{ ONLINE, "online" },
+		{ POSSIBLE_MAP, "possible" },
+		{ PRESENT_MAP, "present" },
+		{ ONLINE_MAP, "online" },
 	};
 
 	if ((len = STRUCT_SIZE("cpumask_t")) < 0)
@@ -864,26 +864,26 @@ in_cpu_map(int map, int cpu)
 
 	switch (map)
 	{
-	case POSSIBLE:
+	case POSSIBLE_MAP:
 		if (!cpu_map_addr("possible")) {
 			error(INFO, "cpu_possible_map does not exist\n");
 			return FALSE;
 		}
-		return (kt->cpu_flags[cpu] & POSSIBLE);
+		return (kt->cpu_flags[cpu] & POSSIBLE_MAP);
 
-	case PRESENT:
+	case PRESENT_MAP:
 		if (!cpu_map_addr("present")) {
 			error(INFO, "cpu_present_map does not exist\n");
 			return FALSE;
 		}
-		return (kt->cpu_flags[cpu] & PRESENT);
+		return (kt->cpu_flags[cpu] & PRESENT_MAP);
 
-	case ONLINE:
+	case ONLINE_MAP:
 		if (!cpu_map_addr("online")) {
 			error(INFO, "cpu_online_map does not exist\n");
 			return FALSE;
 		}
-		return (kt->cpu_flags[cpu] & ONLINE);
+		return (kt->cpu_flags[cpu] & ONLINE_MAP);
 	}
 
 	return FALSE;
@@ -5282,7 +5282,7 @@ dump_kernel_table(int verbose)
 	fprintf(fp, "       cpu_possible_map: ");
 	if (cpu_map_addr("possible")) {
 		for (i = 0; i < nr_cpus; i++) {
-			if (kt->cpu_flags[i] & POSSIBLE)
+			if (kt->cpu_flags[i] & POSSIBLE_MAP)
 				fprintf(fp, "%d ", i);
 		}
 		fprintf(fp, "\n");
@@ -5291,7 +5291,7 @@ dump_kernel_table(int verbose)
 	fprintf(fp, "        cpu_present_map: ");
 	if (cpu_map_addr("present")) {
 		for (i = 0; i < nr_cpus; i++) {
-			if (kt->cpu_flags[i] & PRESENT)
+			if (kt->cpu_flags[i] & PRESENT_MAP)
 				fprintf(fp, "%d ", i);
 		}
 		fprintf(fp, "\n");
@@ -5300,12 +5300,13 @@ dump_kernel_table(int verbose)
 	fprintf(fp, "         cpu_online_map: ");
 	if (cpu_map_addr("online")) {
 		for (i = 0; i < nr_cpus; i++) {
-			if (kt->cpu_flags[i] & ONLINE)
+			if (kt->cpu_flags[i] & ONLINE_MAP)
 				fprintf(fp, "%d ", i);
 		}
 		fprintf(fp, "\n");
 	} else
 		fprintf(fp, "(does not exist)\n");
+
 no_cpu_flags:
 	fprintf(fp, "    vmcoreinfo: \n");
 	fprintf(fp, "      log_buf_SYMBOL: %lx\n", kt->vmcoreinfo.log_buf_SYMBOL);
diff --git a/netdump.c b/netdump.c
index 92c235a..72f71ec 100644
--- a/netdump.c
+++ b/netdump.c
@@ -92,7 +92,7 @@ map_cpus_to_prstatus(void)
 	nrcpus = (kt->kernel_NR_CPUS ? kt->kernel_NR_CPUS : NR_CPUS);
 
 	for (i = 0, j = 0; i < nrcpus; i++) {
-		if (in_cpu_map(ONLINE, i))
+		if (in_cpu_map(ONLINE_MAP, i))
 			nd->nt_prstatus_percpu[i] = nt_ptr[j++];
 	}
 
@@ -780,7 +780,7 @@ get_netdump_panic_task(void)
 		crashing_cpu = -1;
 		if (kernel_symbol_exists("crashing_cpu")) {
 			get_symbol_data("crashing_cpu", sizeof(int), &i);
-			if ((i >= 0) && in_cpu_map(ONLINE, i)) {
+			if ((i >= 0) && in_cpu_map(ONLINE_MAP, i)) {
 				crashing_cpu = i;
 				if (CRASHDEBUG(1))
 					error(INFO, 
diff --git a/ppc.c b/ppc.c
index 742f47b..ae69e8f 100644
--- a/ppc.c
+++ b/ppc.c
@@ -2036,7 +2036,7 @@ ppc_relocate_nt_prstatus_percpu(void **nt_prstatus_percpu,
 	*num_prstatus_notes = 0;
 	nrcpus = (kt->kernel_NR_CPUS ? kt->kernel_NR_CPUS : NR_CPUS);
 	for (i = 0, j = 0; i < nrcpus; i++) {
-		if (!in_cpu_map(ONLINE, i))
+		if (!in_cpu_map(ONLINE_MAP, i))
 			continue;
 		if (verify_crash_note_in_kernel(i))
 			nt_prstatus_percpu[i] = nt_ptr[j++];
diff --git a/ppc64.c b/ppc64.c
index e302ac0..f414a58 100644
--- a/ppc64.c
+++ b/ppc64.c
@@ -2861,11 +2861,11 @@ ppc64_get_cpu_map(void)
 	int map;
 
 	if (cpu_map_addr("possible"))
-		map = POSSIBLE;
+		map = POSSIBLE_MAP;
 	else if (cpu_map_addr("present"))
-		map = PRESENT;
+		map = PRESENT_MAP;
 	else if (cpu_map_addr("online"))
-		map = ONLINE;
+		map = ONLINE_MAP;
 	else {
 		map = 0;
 		error(FATAL,
@@ -2911,15 +2911,15 @@ ppc64_init_cpu_info(void)
 	}
 	switch (map)
 	{
-	case POSSIBLE:
+	case POSSIBLE_MAP:
 		if (cpus > kt->cpus) {
 			i = get_highest_cpu_online() + 1;
 			if (i > kt->cpus)
 				kt->cpus = i;
 		}
 		break;
-	case ONLINE:
-	case PRESENT:
+	case ONLINE_MAP:
+	case PRESENT_MAP:
 		kt->cpus = cpus;
 		break;
 	}
diff --git a/s390.c b/s390.c
index 16cd58c..82d9b42 100644
--- a/s390.c
+++ b/s390.c
@@ -558,7 +558,7 @@ s390_has_cpu(struct bt_info *bt)
 {
 	int cpu = bt->tc->processor;
 
-	if (is_task_active(bt->task) && (kt->cpu_flags[cpu] & ONLINE))
+	if (is_task_active(bt->task) && (kt->cpu_flags[cpu] & ONLINE_MAP))
 		return TRUE;
 	else
 		return FALSE;
@@ -619,7 +619,7 @@ s390_back_trace_cmd(struct bt_info *bt)
 		error(WARNING,
 		"instruction pointer argument ignored on this architecture!\n");
 	}
-	if (is_task_active(bt->task) && !(kt->cpu_flags[cpu] & ONLINE)) {
+	if (is_task_active(bt->task) && !(kt->cpu_flags[cpu] & ONLINE_MAP)) {
 		fprintf(fp, " CPU offline\n");
 		return;
 	}
diff --git a/s390x.c b/s390x.c
index 9294e64..e327843 100644
--- a/s390x.c
+++ b/s390x.c
@@ -872,7 +872,7 @@ s390x_has_cpu(struct bt_info *bt)
 {
 	int cpu = bt->tc->processor;
 
-	if (is_task_active(bt->task) && (kt->cpu_flags[cpu] & ONLINE))
+	if (is_task_active(bt->task) && (kt->cpu_flags[cpu] & ONLINE_MAP))
 		return TRUE;
 	else
 		return FALSE;
@@ -1165,7 +1165,7 @@ static void s390x_back_trace_cmd(struct bt_info *bt)
 		error(WARNING,
 	        "instruction pointer argument ignored on this architecture!\n");
 	}
-	if (is_task_active(bt->task) && !(kt->cpu_flags[cpu] & ONLINE)) {
+	if (is_task_active(bt->task) && !(kt->cpu_flags[cpu] & ONLINE_MAP)) {
 		fprintf(fp, " CPU offline\n");
 		return;
 	}
-- 
1.9.0




More information about the Crash-utility mailing list