From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
To: Simon Horman <horms@verge.net.au>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: [PATCH] kexec: Parse percpu note size from kernel
Date: Tue, 30 Apr 2013 09:12:28 +0800 [thread overview]
Message-ID: <517F1A7C.5000305@cn.fujitsu.com> (raw)
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>
---
kexec/crashdump.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 70817b8..8d88fdf 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;
}
--
1.7.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2013-04-30 1:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 1:12 Zhang Yanfei [this message]
2013-04-30 1:41 ` [PATCH] kexec: Parse percpu note size from kernel Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517F1A7C.5000305@cn.fujitsu.com \
--to=zhangyanfei@cn.fujitsu.com \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox