Blame SOURCES/kexec-tools-2.0.4-Enumerate-all-sys-devices-system-cpu-cpuN-when-they-.patch

3dae34
From 08484c97ecce7df2ded8079c6478a58262007acc Mon Sep 17 00:00:00 2001
3dae34
From: Takao Indoh <indou.takao@jp.fujitsu.com>
3dae34
Date: Thu, 5 Jun 2014 14:10:54 +0900
3dae34
Subject: [PATCH 1/2] Enumerate all /sys/devices/system/cpu/cpuN when they are
3dae34
 discontiguous
3dae34
3dae34
There is a case that the number of /sys/devices/system/cpu/cpuN is not
3dae34
contiguous, for example after cpu hot removing. This patch fixes so that
3dae34
all /sys/devices/system/cpu/cpuN is handled when they are discontiguous.
3dae34
3dae34
Signed-off-by: Takao Indoh <indou.takao@jp.fujitsu.com>
3dae34
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
3dae34
Acked-by: WANG Chao <chaowang@redhat.com>
3dae34
Signed-off-by: Simon Horman <horms@verge.net.au>
3dae34
---
3dae34
 kexec/crashdump-elf.c | 5 ++++-
3dae34
 1 file changed, 4 insertions(+), 1 deletion(-)
3dae34
3dae34
diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
3dae34
index 2baa357..c869347 100644
3dae34
--- a/kexec/crashdump-elf.c
3dae34
+++ b/kexec/crashdump-elf.c
3dae34
@@ -41,6 +41,7 @@ int FUNC(struct kexec_info *info,
3dae34
 	uint64_t vmcoreinfo_addr, vmcoreinfo_len;
3dae34
 	int has_vmcoreinfo = 0;
3dae34
 	int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
3dae34
+	long int count_cpu;
3dae34
 
3dae34
 	if (xen_present())
3dae34
 		nr_cpus = xen_get_nr_phys_cpus();
3dae34
@@ -138,11 +139,13 @@ int FUNC(struct kexec_info *info,
3dae34
 
3dae34
 	/* PT_NOTE program headers. One per cpu */
3dae34
 
3dae34
-	for (i = 0; i < nr_cpus; i++) {
3dae34
+	count_cpu = nr_cpus;
3dae34
+	for (i = 0; count_cpu > 0; i++) {
3dae34
 		if (get_note_info(i, &notes_addr, &notes_len) < 0) {
3dae34
 			/* This cpu is not present. Skip it. */
3dae34
 			continue;
3dae34
 		}
3dae34
+		count_cpu--;
3dae34
 
3dae34
 		phdr = (PHDR *) bufp;
3dae34
 		bufp += sizeof(PHDR);
3dae34
-- 
3dae34
1.9.3
3dae34