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