Hi,
I'd like to re-enable makedumpfile mmap(), since upstream patches are ready.
There are two commits that I want to backport: 1. makedumpfile: Fall back to read() when mmap() fails 2. makedumpfile: Add --non-mmap option to disable mmap() manually
#1 can be applied cleanly on top of our makedumpfile-1.5.4 #2 has conflicts, so I bring in two addtional patches. These two patches are trivial.
I think it's worth to backport #2 to have a switch between mmap and read. It could be used as workaround when mmap has issues again.
v2 -> v1: - fix upstream commit id [dyoung]
WANG Chao (5): makedumpfile: Revert "makedumpfile: disable mmap" makedumpfile: Assign non-printable value as short options makedumpfile: Add help and man message for '--help' makedumpfile: Add --non-mmap option to disable mmap() manually makedumpfile: Fall back to read() when mmap() fails
...umpfile-Add-help-and-man-message-for-help.patch | 43 ++++ ...-non-mmap-option-to-disable-mmap-manually.patch | 161 ++++++++++++++ ...ssign-non-printable-value-as-short-option.patch | 244 +++++++++++++++++++++ ...umpfile-Fall-back-to-read-when-mmap-fails.patch | 38 ++++ kexec-tools-2.0.4-makedumpfile-disable-mmap.patch | 36 --- kexec-tools.spec | 11 +- 6 files changed, 494 insertions(+), 39 deletions(-) create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch delete mode 100644 kexec-tools-2.0.4-makedumpfile-disable-mmap.patch
This reverts commit 2dc9600ad14b8cf29f6eddbf27c7ec90426156aa:
commit 2dc9600 Author: Dave Young dyoung@redhat.com Date: Thu Nov 14 10:51:47 2013 +0800
makedumpfile: disable mmap
There's a kernel bug for mapping mem ranges which end with an address not aligned to page boundry. It's still not resolved in upstream, so let's disable mmap read for now as a workaround.
Once upstream got a right fix we can revert this patch.
Signed-off-by: Dave Young dyoung@redhat.com
Signed-off-by: WANG Chao chaowang@redhat.com --- kexec-tools-2.0.4-makedumpfile-disable-mmap.patch | 36 ----------------------- kexec-tools.spec | 2 -- 2 files changed, 38 deletions(-) delete mode 100644 kexec-tools-2.0.4-makedumpfile-disable-mmap.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-disable-mmap.patch b/kexec-tools-2.0.4-makedumpfile-disable-mmap.patch deleted file mode 100644 index 125b62f..0000000 --- a/kexec-tools-2.0.4-makedumpfile-disable-mmap.patch +++ /dev/null @@ -1,36 +0,0 @@ -makedumpfile: disable mmap read - -There's a kernel bug for mapping mem ranges which end with -an address not aligned to page boundry. It's still not resolved -in upstream, so let's disable mmap read for now as a workaround. - -Once upstream got a right fix we can revert this patch. - -Signed-off-by: Dave Young dyoung@redhat.com ---- - makedumpfile.c | 7 +++++++ - 1 file changed, 7 insertions(+) - ---- kexec-tools/makedumpfile-1.5.4/makedumpfile.c.orig -+++ kexec-tools/makedumpfile-1.5.4/makedumpfile.c -@@ -3144,6 +3144,12 @@ out: - if (info->dump_level & DL_EXCLUDE_FREE) - setup_page_is_buddy(); - -+ /* There's a kernel bug for mapping mem ranges which end with -+ * an address not aligned to page boundry. It's still not resolved -+ * in upstream, so let's disable mmap read for now. -+ */ -+ info->flag_usemmap = FALSE; -+#if 0 - if (!initialize_mmap()) { - /* this kernel does not support mmap of vmcore */ - DEBUG_MSG("Kernel can't mmap vmcore, using reads.\n"); -@@ -3152,6 +3158,7 @@ out: - DEBUG_MSG("read %s with mmap()\n", info->name_memory); - info->flag_usemmap = TRUE; - } -+#endif - - return TRUE; - } diff --git a/kexec-tools.spec b/kexec-tools.spec index 0b948c2..485fe88 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -89,7 +89,6 @@ Patch607: kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffe Patch608: kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch Patch609: kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch Patch610: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch -Patch611: kexec-tools-2.0.4-makedumpfile-disable-mmap.patch Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch
%description @@ -129,7 +128,6 @@ tar -z -x -v -f %{SOURCE19} %patch608 -p1 %patch609 -p1 %patch610 -p1 -%patch611 -p1 %patch001 -p1 %patch002 -p1 %patch003 -p1
This is a backport of the following upstream commit:
commit bd67c1d Author: Baoquan He bhe@redhat.com Date: Tue Jul 2 11:09:20 2013 +0900
[PATCH 1/2] Assign non-printable value as short options.
Characters for short options is limited, and now makedumpfile has considerably many options. As times go on, no enough reasonable letters can be assigned to each functionality with short options.
E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S.
Now assign non-printable value to these kind of short optins, meanwhile define them as indicative MACRO which can make code more readable.
Signed-off-by: Baoquan He bhe@redhat.com
It's needed for applying commit 414d3ed ("Add --non-mmap option to disable mmap() manually").
Signed-off-by: WANG Chao chaowang@redhat.com --- ...ssign-non-printable-value-as-short-option.patch | 244 +++++++++++++++++++++ kexec-tools.spec | 3 +- 2 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch b/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch new file mode 100644 index 0000000..115e3d8 --- /dev/null +++ b/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch @@ -0,0 +1,244 @@ +From bd67c1d5e2633f302b4c0ad50cc830ff7da20b2a Mon Sep 17 00:00:00 2001 +From: Baoquan He bhe@redhat.com +Date: Tue, 2 Jul 2013 11:09:20 +0900 +Subject: [PATCH 1/2] [PATCH 1/2] Assign non-printable value as short options. + +Characters for short options is limited, and now makedumpfile has +considerably many options. As times go on, no enough reasonable +letters can be assigned to each functionality with short options. + +E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S. + +Now assign non-printable value to these kind of short optins, meanwhile +define them as indicative MACRO which can make code more readable. + +Signed-off-by: Baoquan He bhe@redhat.com +--- + makedumpfile.c | 88 +++++++++++++++++++++++++++++----------------------------- + makedumpfile.h | 35 +++++++++++++++++++++++ + 2 files changed, 79 insertions(+), 44 deletions(-) + +diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c +index b42565c..bb72c66 100644 +--- a/makedumpfile-1.5.4/makedumpfile.c ++++ b/makedumpfile-1.5.4/makedumpfile.c +@@ -8555,20 +8555,20 @@ calculate_cyclic_buffer_size(void) { + } + + static struct option longopts[] = { +- {"split", no_argument, NULL, 's'}, +- {"reassemble", no_argument, NULL, 'r'}, +- {"xen-syms", required_argument, NULL, 'y'}, +- {"xen-vmcoreinfo", required_argument, NULL, 'z'}, +- {"xen_phys_start", required_argument, NULL, 'P'}, +- {"message-level", required_argument, NULL, 'm'}, +- {"vtop", required_argument, NULL, 'V'}, +- {"dump-dmesg", no_argument, NULL, 'M'}, +- {"config", required_argument, NULL, 'C'}, +- {"help", no_argument, NULL, 'h'}, +- {"diskset", required_argument, NULL, 'k'}, +- {"non-cyclic", no_argument, NULL, 'Y'}, +- {"cyclic-buffer", required_argument, NULL, 'Z'}, +- {"eppic", required_argument, NULL, 'S'}, ++ {"split", no_argument, NULL, OPT_SPLIT}, ++ {"reassemble", no_argument, NULL, OPT_REASSEMBLE}, ++ {"xen-syms", required_argument, NULL, OPT_XEN_SYMS}, ++ {"xen-vmcoreinfo", required_argument, NULL, OPT_XEN_VMCOREINFO}, ++ {"xen_phys_start", required_argument, NULL, OPT_XEN_PHYS_START}, ++ {"message-level", required_argument, NULL, OPT_MESSAGE_LEVEL}, ++ {"vtop", required_argument, NULL, OPT_VTOP}, ++ {"dump-dmesg", no_argument, NULL, OPT_DUMP_DMESG}, ++ {"config", required_argument, NULL, OPT_CONFIG}, ++ {"help", no_argument, NULL, OPT_HELP}, ++ {"diskset", required_argument, NULL, OPT_DISKSET}, ++ {"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC}, ++ {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, ++ {"eppic", required_argument, NULL, OPT_EPPIC}, + {0, 0, 0, 0} + }; + +@@ -8597,29 +8597,29 @@ main(int argc, char *argv[]) + + info->block_order = DEFAULT_ORDER; + message_level = DEFAULT_MSG_LEVEL; +- while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lMpRrsvXx:", longopts, ++ while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts, + NULL)) != -1) { + switch (opt) { +- case 'b': ++ case OPT_BLOCK_ORDER: + info->block_order = atoi(optarg); + break; +- case 'C': ++ case OPT_CONFIG: + info->name_filterconfig = optarg; + break; +- case 'c': ++ case OPT_COMPRESS_ZLIB: + info->flag_compress = DUMP_DH_COMPRESSED_ZLIB; + break; +- case 'D': ++ case OPT_DEBUG: + flag_debug = TRUE; + break; +- case 'd': ++ case OPT_DUMP_LEVEL: + if (!parse_dump_level(optarg)) + goto out; + break; +- case 'E': ++ case OPT_ELF_DUMPFILE: + info->flag_elf_dumpfile = 1; + break; +- case 'F': ++ case OPT_FLATTEN: + info->flag_flatten = 1; + /* + * All messages are output to STDERR because STDOUT is +@@ -8627,75 +8627,75 @@ main(int argc, char *argv[]) + */ + flag_strerr_message = TRUE; + break; +- case 'f': ++ case OPT_FORCE: + info->flag_force = 1; + break; +- case 'g': ++ case OPT_GENERATE_VMCOREINFO: + info->flag_generate_vmcoreinfo = 1; + info->name_vmcoreinfo = optarg; + break; +- case 'h': ++ case OPT_HELP: + info->flag_show_usage = 1; + break; +- case 'i': ++ case OPT_READ_VMCOREINFO: + info->flag_read_vmcoreinfo = 1; + info->name_vmcoreinfo = optarg; + break; +- case 'k': ++ case OPT_DISKSET: + if (!sadump_add_diskset_info(optarg)) + goto out; + info->flag_sadump_diskset = 1; + break; +- case 'l': ++ case OPT_COMPRESS_LZO: + info->flag_compress = DUMP_DH_COMPRESSED_LZO; + break; +- case 'm': ++ case OPT_MESSAGE_LEVEL: + message_level = atoi(optarg); + break; +- case 'M': ++ case OPT_DUMP_DMESG: + info->flag_dmesg = 1; + break; +- case 'p': ++ case OPT_COMPRESS_SNAPPY: + info->flag_compress = DUMP_DH_COMPRESSED_SNAPPY; + break; +- case 'P': ++ case OPT_XEN_PHYS_START: + info->xen_phys_start = strtoul(optarg, NULL, 0); + break; +- case 'R': ++ case OPT_REARRANGE: + info->flag_rearrange = 1; + break; +- case 's': ++ case OPT_SPLIT: + info->flag_split = 1; + break; +- case 'S': ++ case OPT_EPPIC: + info->name_eppic_config = optarg; + break; +- case 'r': ++ case OPT_REASSEMBLE: + info->flag_reassemble = 1; + break; +- case 'V': ++ case OPT_VTOP: + info->vaddr_for_vtop = strtoul(optarg, NULL, 0); + break; +- case 'v': ++ case OPT_VERSION: + info->flag_show_version = 1; + break; +- case 'X': ++ case OPT_EXCLUDE_XEN_DOM: + info->flag_exclude_xen_dom = 1; + break; +- case 'x': ++ case OPT_VMLINUX: + info->name_vmlinux = optarg; + break; +- case 'y': ++ case OPT_XEN_SYMS: + info->name_xen_syms = optarg; + break; +- case 'Y': ++ case OPT_NON_CYCLIC: + info->flag_cyclic = FALSE; + break; +- case 'z': ++ case OPT_XEN_VMCOREINFO: + info->flag_read_vmcoreinfo = 1; + info->name_vmcoreinfo = optarg; + break; +- case 'Z': ++ case OPT_CYCLIC_BUFFER: + info->bufsize_cyclic = atoi(optarg); + break; + case '?': +diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h +index a5826e0..79d4702 100644 +--- a/makedumpfile-1.5.4/makedumpfile.h ++++ b/makedumpfile-1.5.4/makedumpfile.h +@@ -1671,6 +1671,41 @@ struct elf_prstatus { + #endif + + /* ++ * Below are options which getopt_long can recognize. From OPT_START options are ++ * non-printable, just used for implementation. ++ */ ++#define OPT_BLOCK_ORDER 'b' ++#define OPT_COMPRESS_ZLIB 'c' ++#define OPT_DEBUG 'D' ++#define OPT_DUMP_LEVEL 'd' ++#define OPT_ELF_DUMPFILE 'E' ++#define OPT_FLATTEN 'F' ++#define OPT_FORCE 'f' ++#define OPT_GENERATE_VMCOREINFO 'g' ++#define OPT_HELP 'h' ++#define OPT_READ_VMCOREINFO 'i' ++#define OPT_COMPRESS_LZO 'l' ++#define OPT_COMPRESS_SNAPPY 'p' ++#define OPT_REARRANGE 'R' ++#define OPT_VERSION 'v' ++#define OPT_EXCLUDE_XEN_DOM 'X' ++#define OPT_VMLINUX 'x' ++#define OPT_START 256 ++#define OPT_SPLIT OPT_START+0 ++#define OPT_REASSEMBLE OPT_START+1 ++#define OPT_XEN_SYMS OPT_START+2 ++#define OPT_XEN_VMCOREINFO OPT_START+3 ++#define OPT_XEN_PHYS_START OPT_START+4 ++#define OPT_MESSAGE_LEVEL OPT_START+5 ++#define OPT_VTOP OPT_START+6 ++#define OPT_DUMP_DMESG OPT_START+7 ++#define OPT_CONFIG OPT_START+8 ++#define OPT_DISKSET OPT_START+9 ++#define OPT_NON_CYCLIC OPT_START+10 ++#define OPT_CYCLIC_BUFFER OPT_START+11 ++#define OPT_EPPIC OPT_START+12 ++ ++/* + * Function Prototype. + */ + unsigned long long get_num_dumpable_cyclic(void); +-- +1.8.4.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 485fe88..78a8277 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -90,6 +90,7 @@ Patch608: kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-requi Patch609: kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch Patch610: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch +Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch
%description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -133,7 +134,7 @@ tar -z -x -v -f %{SOURCE19} %patch003 -p1 %patch612 -p1 %patch302 -p1 - +%patch613 -p1
tar -z -x -v -f %{SOURCE13}
This is a backport of the following upstream commit:
commit eb708ce Author: Baoquan He bhe@redhat.com Date: Tue Jul 2 11:11:07 2013 +0900
[PATCH 2/2] Add help and man message for '--help'.
Conventionally '-h' and '--help' are all provided. Currently makedumpfile lacks help and man message for '--help'. Here add it.
Signed-off-by: Baoquan He bhe@redhat.com
It's needed for applying commit 414d3ed ("Add --non-mmap option to disable mmap() manually").
Signed-off-by: WANG Chao chaowang@redhat.com --- ...umpfile-Add-help-and-man-message-for-help.patch | 43 ++++++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 45 insertions(+) create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch b/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch new file mode 100644 index 0000000..c834227 --- /dev/null +++ b/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch @@ -0,0 +1,43 @@ +From eb708cedde4ed48dde5a918a23b2c3b8235df6c5 Mon Sep 17 00:00:00 2001 +From: Baoquan He bhe@redhat.com +Date: Tue, 2 Jul 2013 11:11:07 +0900 +Subject: [PATCH 2/2] [PATCH 2/2] Add help and man message for '--help'. + +Conventionally '-h' and '--help' are all provided. Currently makedumpfile +lacks help and man message for '--help'. Here add it. + +Signed-off-by: Baoquan He bhe@redhat.com +--- + makedumpfile.8 | 2 +- + print_info.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile-1.5.4/makedumpfile.8 b/makedumpfile-1.5.4/makedumpfile.8 +index adeb811..f50a011 100644 +--- a/makedumpfile-1.5.4/makedumpfile.8 ++++ b/makedumpfile-1.5.4/makedumpfile.8 +@@ -539,7 +539,7 @@ order from left to right. \fIVMCORE\fRs are assembled into a single + Print debugging message. + + .TP +-\fB-h\fR ++\fB-h (--help)\fR + Show help message and LZO/snappy support status (enabled/disabled). + + .TP +diff --git a/makedumpfile-1.5.4/print_info.c b/makedumpfile-1.5.4/print_info.c +index 06939e0..3527970 100644 +--- a/makedumpfile-1.5.4/print_info.c ++++ b/makedumpfile-1.5.4/print_info.c +@@ -255,7 +255,7 @@ print_usage(void) + MSG(" [-f]:\n"); + MSG(" Overwrite DUMPFILE even if it already exists.\n"); + MSG("\n"); +- MSG(" [-h]:\n"); ++ MSG(" [-h, --help]:\n"); + MSG(" Show help message and LZO/snappy support status (enabled/disabled).\n"); + MSG("\n"); + MSG(" [-v]:\n"); +-- +1.8.4.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 78a8277..1edd4ed 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -91,6 +91,7 @@ Patch609: kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initializatio Patch610: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch +Patch614: kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch
%description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -135,6 +136,7 @@ tar -z -x -v -f %{SOURCE19} %patch612 -p1 %patch302 -p1 %patch613 -p1 +%patch614 -p1
tar -z -x -v -f %{SOURCE13}
This is a backport of the following upstream commit:
commit a895dc8 Author: Atsushi Kumagai kumagai-atsushi@mxc.nes.nec.co.jp Date: Thu Dec 12 16:40:12 2013 +0900
[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
Having this patch, user can switch between mmap() and read() when accessing vmcore. Whenever user feels necessary to use readmem on vmcore (buggy code in mmap path, debug purpose, etc.), --non-mmap can do this favor.
Signed-off-by: WANG Chao chaowang@redhat.com --- ...-non-mmap-option-to-disable-mmap-manually.patch | 161 +++++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 163 insertions(+) create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch b/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch new file mode 100644 index 0000000..8a9ee47 --- /dev/null +++ b/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch @@ -0,0 +1,161 @@ +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 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 1edd4ed..c83cc64 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -92,6 +92,7 @@ Patch610: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch Patch614: kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch +Patch615: kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch
%description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -137,6 +138,7 @@ tar -z -x -v -f %{SOURCE19} %patch302 -p1 %patch613 -p1 %patch614 -p1 +%patch615 -p1
tar -z -x -v -f %{SOURCE13}
This is a backport of the following upstream commit:
commit 7c770ed Author: Atsushi Kumagai kumagai-atsushi@mxc.nes.nec.co.jp Date: Thu Dec 12 16:40:31 2013 +0900
[PATCH] Fall back to read() when mmap() fails.
This is a fall back path for mmap(). This patch disables mmap() when facing the issues related to mmap(), and read() will be used to read vmcore instead.
Signed-off-by: Atsushi Kumagai kumagai-atsushi@mxc.nes.nec.co.jp
mmap() file operation on vmcore is working properly when the page being accessed has different attributes on different part (ie. two different type of memory ranges are overlapping).
A fall back mechanism is introduced in this patch, in case mmap() fails, switch to read() afterwards.
Signed-off-by: WANG Chao chaowang@redhat.com --- ...umpfile-Fall-back-to-read-when-mmap-fails.patch | 38 ++++++++++++++++++++++ kexec-tools.spec | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch b/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch new file mode 100644 index 0000000..a4edb75 --- /dev/null +++ b/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch @@ -0,0 +1,38 @@ +From 7c770ed052d8452f5d7ce027b23d1b77cf6fbce7 Mon Sep 17 00:00:00 2001 +From: Atsushi Kumagai kumagai-atsushi@mxc.nes.nec.co.jp +Date: Thu, 12 Dec 2013 16:40:31 +0900 +Subject: [PATCH 2/2] [PATCH] Fall back to read() when mmap() fails. + +This is a fall back path for mmap(). +This patch disables mmap() when facing the issues related to mmap(), +and read() will be used to read vmcore instead. + +Signed-off-by: Atsushi Kumagai kumagai-atsushi@mxc.nes.nec.co.jp +--- + makedumpfile.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c +index b3af28b..20f107e 100644 +--- a/makedumpfile-1.5.4/makedumpfile.c ++++ b/makedumpfile-1.5.4/makedumpfile.c +@@ -324,7 +324,15 @@ read_from_vmcore(off_t offset, void *bufptr, unsigned long size) + if (!read_with_mmap(offset, bufptr, size)) { + ERRMSG("Can't read the dump memory(%s) with mmap().\n", + info->name_memory); +- return FALSE; ++ ++ ERRMSG("This kernel might have some problems about mmap().\n"); ++ ERRMSG("read() will be used instead of mmap() from now.\n"); ++ ++ /* ++ * Fall back to read(). ++ */ ++ info->flag_usemmap = MMAP_DISABLE; ++ read_from_vmcore(offset, bufptr, size); + } + } else { + if (lseek(info->fd_memory, offset, SEEK_SET) == failed) { +-- +1.8.4.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index c83cc64..4bf50af 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -93,6 +93,7 @@ Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch Patch614: kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch Patch615: kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch +Patch616: kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch
%description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -139,6 +140,7 @@ tar -z -x -v -f %{SOURCE19} %patch613 -p1 %patch614 -p1 %patch615 -p1 +%patch616 -p1
tar -z -x -v -f %{SOURCE13}
On Wed, Jan 08, 2014 at 02:55:03PM +0800, WANG Chao wrote:
Hi,
I'd like to re-enable makedumpfile mmap(), since upstream patches are ready.
There are two commits that I want to backport:
- makedumpfile: Fall back to read() when mmap() fails
- makedumpfile: Add --non-mmap option to disable mmap() manually
#1 can be applied cleanly on top of our makedumpfile-1.5.4 #2 has conflicts, so I bring in two addtional patches. These two patches are trivial.
I think it's worth to backport #2 to have a switch between mmap and read. It could be used as workaround when mmap has issues again.
v2 -> v1:
- fix upstream commit id [dyoung]
These patches look good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
Vivek
WANG Chao (5): makedumpfile: Revert "makedumpfile: disable mmap" makedumpfile: Assign non-printable value as short options makedumpfile: Add help and man message for '--help' makedumpfile: Add --non-mmap option to disable mmap() manually makedumpfile: Fall back to read() when mmap() fails
...umpfile-Add-help-and-man-message-for-help.patch | 43 ++++ ...-non-mmap-option-to-disable-mmap-manually.patch | 161 ++++++++++++++ ...ssign-non-printable-value-as-short-option.patch | 244 +++++++++++++++++++++ ...umpfile-Fall-back-to-read-when-mmap-fails.patch | 38 ++++ kexec-tools-2.0.4-makedumpfile-disable-mmap.patch | 36 --- kexec-tools.spec | 11 +- 6 files changed, 494 insertions(+), 39 deletions(-) create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch create mode 100644 kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch delete mode 100644 kexec-tools-2.0.4-makedumpfile-disable-mmap.patch
-- 1.8.4.2
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec