kexec-tools/kexec-tools-2.0.4-makedumpf...

162 lines
5.4 KiB
Diff

From a895dc8f2a17f7dac9d3d63de1cea4720557625d Mon Sep 17 00:00:00 2001
From: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Date: Thu, 12 Dec 2013 16:40:12 +0900
Subject: [PATCH 1/2] [PATCH] Add --non-mmap option to disable mmap() manually.
When --non-mmap option is specified, makedumpfile doesn't use
mmap() even if /proc/vmcore supports mmap().
Signed-off-by: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
---
makedumpfile.8 | 11 +++++++++++
makedumpfile.c | 29 +++++++++++++++++++----------
makedumpfile.h | 9 +++++++++
print_info.c | 6 ++++++
4 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/makedumpfile-1.5.4/makedumpfile.8 b/makedumpfile-1.5.4/makedumpfile.8
index f50a011..227b6f7 100644
--- a/makedumpfile-1.5.4/makedumpfile.8
+++ b/makedumpfile-1.5.4/makedumpfile.8
@@ -395,6 +395,17 @@ If you feel the cyclic mode is too slow, please try this mode.
# makedumpfile \-\-non\-cyclic \-d 31 \-x vmlinux /proc/vmcore dumpfile
.TP
+\fB\-\-non\-mmap\fR
+Never use \fBmmap(2)\fR to read \fIVMCORE\fR even if it supports \fBmmap(2)\fR.
+Generally, reading \fIVMCORE\fR with \fBmmap(2)\fR is faster than without it,
+so ordinary users don't need to specify this option.
+This option is mainly for debugging.
+.br
+.B Example:
+.br
+# makedumpfile \-\-non\-mmap \-d 31 \-x vmlinux /proc/vmcore dumpfile
+
+.TP
\fB\-\-xen-syms\fR \fIXEN-SYMS\fR
Specify the \fIXEN-SYMS\fR with debug information to analyze the xen's memory usage.
This option extracts the part of xen and domain-0.
diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
index 600fb5d..b3af28b 100644
--- a/makedumpfile-1.5.4/makedumpfile.c
+++ b/makedumpfile-1.5.4/makedumpfile.c
@@ -272,7 +272,7 @@ update_mmap_range(off_t offset, int initial) {
static int
is_mapped_with_mmap(off_t offset) {
- if (info->flag_usemmap
+ if (info->flag_usemmap == MMAP_ENABLE
&& offset >= info->mmap_start_offset
&& offset < info->mmap_end_offset)
return TRUE;
@@ -320,7 +320,7 @@ read_from_vmcore(off_t offset, void *bufptr, unsigned long size)
{
const off_t failed = (off_t)-1;
- if (info->flag_usemmap) {
+ if (info->flag_usemmap == MMAP_ENABLE) {
if (!read_with_mmap(offset, bufptr, size)) {
ERRMSG("Can't read the dump memory(%s) with mmap().\n",
info->name_memory);
@@ -3175,14 +3175,14 @@ out:
if (info->dump_level & DL_EXCLUDE_FREE)
setup_page_is_buddy();
- if (!initialize_mmap()) {
- /* this kernel does not support mmap of vmcore */
- DEBUG_MSG("Kernel can't mmap vmcore, using reads.\n");
- info->flag_usemmap = FALSE;
+ if (info->flag_usemmap == MMAP_TRY && initialize_mmap()) {
+ DEBUG_MSG("mmap() is available on the kernel.\n");
+ info->flag_usemmap = MMAP_ENABLE;
} else {
- DEBUG_MSG("read %s with mmap()\n", info->name_memory);
- info->flag_usemmap = TRUE;
- }
+ DEBUG_MSG("The kernel doesn't support mmap(),");
+ DEBUG_MSG("read() will be used instead.\n");
+ info->flag_usemmap = MMAP_DISABLE;
+ }
return TRUE;
}
@@ -8947,6 +8947,7 @@ static struct option longopts[] = {
{"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC},
{"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER},
{"eppic", required_argument, NULL, OPT_EPPIC},
+ {"non-mmap", no_argument, NULL, OPT_NON_MMAP},
{0, 0, 0, 0}
};
@@ -8972,7 +8973,12 @@ main(int argc, char *argv[])
* By default, makedumpfile works in constant memory space.
*/
info->flag_cyclic = TRUE;
-
+
+ /*
+ * By default, makedumpfile try to use mmap(2) to read /proc/vmcore.
+ */
+ info->flag_usemmap = MMAP_TRY;
+
info->block_order = DEFAULT_ORDER;
message_level = DEFAULT_MSG_LEVEL;
while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts,
@@ -9069,6 +9075,9 @@ main(int argc, char *argv[])
case OPT_NON_CYCLIC:
info->flag_cyclic = FALSE;
break;
+ case OPT_NON_MMAP:
+ info->flag_usemmap = MMAP_DISABLE;
+ break;
case OPT_XEN_VMCOREINFO:
info->flag_read_vmcoreinfo = 1;
info->name_vmcoreinfo = optarg;
diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h
index 517e16e..fe88eff 100644
--- a/makedumpfile-1.5.4/makedumpfile.h
+++ b/makedumpfile-1.5.4/makedumpfile.h
@@ -128,6 +128,14 @@ enum {
MADDR_XEN
};
+/*
+ * State of mmap(2)
+ */
+enum {
+ MMAP_DISABLE,
+ MMAP_TRY,
+ MMAP_ENABLE,
+};
static inline int
test_bit(int nr, unsigned long addr)
@@ -1741,6 +1749,7 @@ struct elf_prstatus {
#define OPT_NON_CYCLIC OPT_START+10
#define OPT_CYCLIC_BUFFER OPT_START+11
#define OPT_EPPIC OPT_START+12
+#define OPT_NON_MMAP OPT_START+13
/*
* Function Prototype.
diff --git a/makedumpfile-1.5.4/print_info.c b/makedumpfile-1.5.4/print_info.c
index d7a8600..90b6cee 100644
--- a/makedumpfile-1.5.4/print_info.c
+++ b/makedumpfile-1.5.4/print_info.c
@@ -196,6 +196,12 @@ print_usage(void)
MSG(" same as v1.4.4 or before.\n");
MSG(" If you feel the cyclic mode is too slow, please try this mode.\n");
MSG("\n");
+ MSG(" [--non-mmap]:\n");
+ MSG(" Never use mmap(2) to read VMCORE even if it supports mmap(2).\n");
+ MSG(" Generally, reading VMCORE with mmap(2) is faster than without it,\n");
+ MSG(" so ordinary users don't need to specify this option.\n");
+ MSG(" This option is mainly for debugging.\n");
+ MSG("\n");
MSG(" [--xen-syms XEN-SYMS]:\n");
MSG(" Specify the XEN-SYMS to analyze Xen's memory usage.\n");
MSG("\n");
--
1.8.4.2