[v1 2/5] kexec: add resource for normal kexec region
From: Pavel Tatashin
Date: Mon Jul 08 2019 - 17:15:50 EST
crashk_res resource is used to reserve memory for crash kernel. There is
also, however, a benefit to reserve memory for normal kernel to speed up
reboot performance. This is because during regular kexec reboot, kernel
performs relocations to the final destination of the loaded segments, and
the relocation might take a long time especially if initramfs is big.
Therefore, similarly to crashk_res, add kexeck_res that will be used to
reserve memory for normal kexec kernel.
Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
---
include/linux/ioport.h | 1 +
include/linux/kexec.h | 6 ++++--
kernel/kexec_core.c | 9 +++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index da0ebaec25f0..3b18a3c112f3 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -133,6 +133,7 @@ enum {
IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5,
IORES_DESC_DEVICE_PRIVATE_MEMORY = 6,
IORES_DESC_DEVICE_PUBLIC_MEMORY = 7,
+ IORES_DESC_KEXEC_KERNEL = 8,
};
/* helpers to define resources */
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index b9b1bc5f9669..4c1121b385fb 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -303,12 +303,14 @@ extern int kexec_load_disabled;
#define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \
KEXEC_FILE_NO_INITRAMFS)
-/* Location of a reserved region to hold the crash kernel.
- */
+/* Location of a reserved region to hold the crash kernel. */
extern struct resource crashk_res;
extern struct resource crashk_low_res;
extern note_buf_t __percpu *crash_notes;
+/* Location of a reserved region to hold normal kexec kernel. */
+extern struct resource kexeck_res;
+
/* flag to track if kexec reboot is in progress */
extern bool kexec_in_progress;
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 2c5b72863b7b..932feadbeb3a 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -70,6 +70,15 @@ struct resource crashk_low_res = {
.desc = IORES_DESC_CRASH_KERNEL
};
+/* Location of the reserved area for the normal kexec kernel */
+struct resource kexeck_res = {
+ .name = "Kexec kernel",
+ .start = 0,
+ .end = 0,
+ .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
+ .desc = IORES_DESC_KEXEC_KERNEL
+};
+
int kexec_should_crash(struct task_struct *p)
{
/*
--
2.22.0