[PATCH 1/2] Enumerate all /sys/devices/system/cpu/cpuN when they are discontiguous

Takao Indoh indou.takao at jp.fujitsu.com
Wed Jun 4 22:10:54 PDT 2014


There is a case that the number of /sys/devices/system/cpu/cpuN is not
contiguous, for example after cpu hot removing. This patch fixes so that
all /sys/devices/system/cpu/cpuN is handled when they are discontiguous.

Signed-off-by: Takao Indoh <indou.takao at jp.fujitsu.com>
---
 kexec/crashdump-elf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index 2baa357..c869347 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -41,6 +41,7 @@ int FUNC(struct kexec_info *info,
 	uint64_t vmcoreinfo_addr, vmcoreinfo_len;
 	int has_vmcoreinfo = 0;
 	int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
+	long int count_cpu;
 
 	if (xen_present())
 		nr_cpus = xen_get_nr_phys_cpus();
@@ -138,11 +139,13 @@ int FUNC(struct kexec_info *info,
 
 	/* PT_NOTE program headers. One per cpu */
 
-	for (i = 0; i < nr_cpus; i++) {
+	count_cpu = nr_cpus;
+	for (i = 0; count_cpu > 0; i++) {
 		if (get_note_info(i, &notes_addr, &notes_len) < 0) {
 			/* This cpu is not present. Skip it. */
 			continue;
 		}
+		count_cpu--;
 
 		phdr = (PHDR *) bufp;
 		bufp += sizeof(PHDR);
-- 
1.9.3





More information about the kexec mailing list