[PATCH v1 5/7] crashdump: introduce --elfcorehdrsz option

Eric DeVolder eric.devolder at oracle.com
Thu Oct 20 10:03:42 PDT 2022


This option provides a means for tuning the size of the elfcorehdr
buffer segment.

The motivation for this option is that a maximum-sized elfcorehdr
can be several MiB, whereas a typical just-large-enough tends to be
several KiB. This order of magnitude difference may be unpalatable
for some users, and so this option allows the size to be dialed in.

See patch "crashdump: create get_elfcorehdrsz()" for more info.

Signed-off-by: Eric DeVolder <eric.devolder at oracle.com>
---
 kexec/kexec.c | 11 +++++++++++
 kexec/kexec.h |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index d2379cb..5a54c07 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -63,6 +63,7 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 int do_hotplug = 0;
+unsigned long long elfcorehdrsz = 0;
 
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
@@ -1080,6 +1081,7 @@ void usage(void)
 	       "                      0 if not.\n"
 	       " --hotplug            Enable kernel modification of the elfcorehdr, in\n"
 	       "                      response to hot un/plug changes to CPUs and memory\n"
+	       " --elfcorehdrsz       Specify the size of the elfcorehdr buffer segment\n"
 	       "\n"
 	       "Supported kernel file types and options: \n");
 	for (i = 0; i < file_types; i++) {
@@ -1591,6 +1593,15 @@ int main(int argc, char *argv[])
 		case OPT_HOTPLUG:
 			do_hotplug = 1;
 			break;
+		case OPT_ELFCOREHDRSZ:
+			elfcorehdrsz = strtoul(optarg, &endptr, 0);
+			if (*endptr) {
+				fprintf(stderr,
+					"Bad option value in --elfcorehdrsz=%s\n", optarg);
+				usage();
+				return 1;
+			}
+			break;
 		default:
 			break;
 		}
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 9675e79..ae55d2d 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -233,7 +233,8 @@ extern int file_types;
 #define OPT_LOAD_LIVE_UPDATE	263
 #define OPT_EXEC_LIVE_UPDATE	264
 #define OPT_HOTPLUG		265
-#define OPT_MAX			266
+#define OPT_ELFCOREHDRSZ	266
+#define OPT_MAX			267
 #define KEXEC_OPTIONS \
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
@@ -261,6 +262,7 @@ extern int file_types;
 	{ "status",		0, 0, OPT_STATUS }, \
 	{ "print-ckr-size",     0, 0, OPT_PRINT_CKR_SIZE }, \
 	{ "hotplug",		0, 0, OPT_HOTPLUG }, \
+	{ "elfcorehdrsz",	1, 0, OPT_ELFCOREHDRSZ }, \
 
 
 #define KEXEC_OPT_STR "h?vdfixyluet:pscaS"
@@ -299,6 +301,7 @@ extern long int get_nr_cpus(void);
 extern int ifdown(void);
 
 extern int do_hotplug;
+extern unsigned long long elfcorehdrsz;
 
 extern char purgatory[];
 extern size_t purgatory_size;
-- 
2.31.1




More information about the kexec mailing list