From 08484c97ecce7df2ded8079c6478a58262007acc Mon Sep 17 00:00:00 2001
From: Takao Indoh <indou.takao@jp.fujitsu.com>
Date: Thu, 5 Jun 2014 14:10:54 +0900
Subject: [PATCH 1/2] Enumerate all /sys/devices/system/cpu/cpuN when they are
discontiguous
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@jp.fujitsu.com>
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
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, ¬es_addr, ¬es_len) < 0) {
/* This cpu is not present. Skip it. */
continue;
}
+ count_cpu--;
phdr = (PHDR *) bufp;
bufp += sizeof(PHDR);
--
1.9.3