diff options
author | Zhang Yanfei <zhangyanfei@cn.fujitsu.com> | 2013-04-30 09:12:28 +0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-04-30 10:35:25 +0900 |
commit | f26892364d694df5b1548170b785b01849887521 (patch) | |
tree | 3c0c5e756f34ad6ae56788b8946ac49767b2476c | |
parent | c6e7799c7fb5c0b5c982e7536471301acba4b324 (diff) | |
download | kexec-tools-f26892364d694df5b1548170b785b01849887521.tar.gz |
kexec: Parse percpu note size from kernel
We used 1024 as the percpu crash note size. But for new kernel that
exports the real crash note size, we should parse it instead of
using 1024.
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/crashdump.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/kexec/crashdump.c b/kexec/crashdump.c index 70817b87..8d88fdf8 100644 --- a/kexec/crashdump.c +++ b/kexec/crashdump.c @@ -65,6 +65,7 @@ unsigned long crash_architecture(struct crash_elf_info *elf_info) int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) { char crash_notes[PATH_MAX]; + char crash_notes_size[PATH_MAX]; char line[MAX_LINE]; FILE *fp; struct stat cpu_stat; @@ -101,12 +102,27 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) if (count != 1) die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); *addr = (uint64_t) temp; - *len = MAX_NOTE_BYTES; /* we should get this from the kernel instead */ + fclose(fp); + + *len = MAX_NOTE_BYTES; + sprintf(crash_notes_size, + "/sys/devices/system/cpu/cpu%d/crash_notes_size", cpu); + fp = fopen(crash_notes_size, "r"); + if (fp) { + if (!fgets(line, sizeof(line), fp)) + die("Cannot parse %s: %s\n", + crash_notes_size, strerror(errno)); + count = sscanf(line, "%Lu", &temp); + if (count != 1) + die("Cannot parse %s: %s\n", + crash_notes_size, strerror(errno)); + *len = (uint64_t) temp; + fclose(fp); + } - dbgprintf("%s: crash_notes addr = %Lx\n", __FUNCTION__, - (unsigned long long)*addr); + dbgprintf("%s: crash_notes addr = %Lx, size = %Lu\n", __FUNCTION__, + (unsigned long long)*addr, (unsigned long long)*len); - fclose(fp); return 0; } |