* [PATCH v5 1/8] memblock: introduce MEMBLOCK_NODUMP flag
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 2/8] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Add MEMBLOCK_NODUMP to mark regions that should be excluded from
kdump vmcores.
The flag is meant for reserved memory that carries no data useful for
crash analysis. Reusable reserved regions such as CMA may hold useful
data, so these regions must not be marked MEMBLOCK_NODUMP. Subsequent
patches wire this up for /reserved-memory and /memreserve/ entries.
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
include/linux/memblock.h | 9 +++++++++
mm/memblock.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index d62db9e776cf..b2fcf11fba2b 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -52,6 +52,8 @@ extern unsigned long long max_possible_pfn;
* kernel that we know is good to use. It is the only memory that
* allocations may happen from in this phase.
* @MEMBLOCK_RSRV_HUGETLB: memory is reserved for hugetlb pages
+ * @MEMBLOCK_NODUMP: exclude from kdump vmcore. It carries no data useful
+ * for crash analysis (e.g. firmware carveouts).
*/
enum memblock_flags {
MEMBLOCK_NONE = 0x0, /* No special request */
@@ -63,6 +65,7 @@ enum memblock_flags {
MEMBLOCK_RSRV_KERN = 0x20, /* memory reserved for kernel use */
MEMBLOCK_KHO_SCRATCH = 0x40, /* scratch memory for kexec handover */
MEMBLOCK_RSRV_HUGETLB = 0x80, /* memory reserved for hugetlb pages */
+ MEMBLOCK_NODUMP = 0x100,/* exclude from kdump vmcore */
};
/**
@@ -160,6 +163,7 @@ int memblock_reserved_mark_noinit(phys_addr_t base, phys_addr_t size);
int memblock_reserved_mark_kern(phys_addr_t base, phys_addr_t size);
int memblock_mark_kho_scratch(phys_addr_t base, phys_addr_t size);
int memblock_clear_kho_scratch(phys_addr_t base, phys_addr_t size);
+int memblock_mark_nodump(phys_addr_t base, phys_addr_t size);
void memblock_free(void *ptr, size_t size);
void reset_all_zones_managed_pages(void);
@@ -306,6 +310,11 @@ static inline bool memblock_is_kho_scratch(struct memblock_region *m)
return m->flags & MEMBLOCK_KHO_SCRATCH;
}
+static inline bool memblock_is_nodump(struct memblock_region *m)
+{
+ return m->flags & MEMBLOCK_NODUMP;
+}
+
int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn,
unsigned long *end_pfn);
void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
diff --git a/mm/memblock.c b/mm/memblock.c
index 9ce86349a29f..79231634c25b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1204,6 +1204,21 @@ __init int memblock_clear_kho_scratch(phys_addr_t base, phys_addr_t size)
MEMBLOCK_KHO_SCRATCH);
}
+/**
+ * memblock_mark_nodump - Mark a memory region with flag MEMBLOCK_NODUMP.
+ * @base: the base phys addr of the region
+ * @size: the size of the region
+ *
+ * Mark the region as not to be included in crash dumps.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int __init_memblock memblock_mark_nodump(phys_addr_t base, phys_addr_t size)
+{
+ return memblock_setclr_flag(&memblock.memory, base, size, 1,
+ MEMBLOCK_NODUMP);
+}
+
static bool should_skip_region(struct memblock_type *type,
struct memblock_region *m,
int nid, int flags)
@@ -2886,6 +2901,7 @@ static const char * const flagname[] = {
[ilog2(MEMBLOCK_RSRV_NOINIT)] = "RSV_NIT",
[ilog2(MEMBLOCK_RSRV_KERN)] = "RSV_KERN",
[ilog2(MEMBLOCK_KHO_SCRATCH)] = "KHO_SCRATCH",
+ [ilog2(MEMBLOCK_NODUMP)] = "NODUMP",
};
static int memblock_debug_show(struct seq_file *m, void *private)
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 2/8] of: reserved_mem: add dumpable flag to opt-in vmcore
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
2026-08-06 9:35 ` [PATCH v5 1/8] memblock: introduce MEMBLOCK_NODUMP flag Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 3/8] of: reserved_mem: mark /reserved-memory entries with MEMBLOCK_NODUMP Wandun Chen
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Add a 'dumpable' flag to struct reserved_mem to decide whether a
reserved area should be included in the kdump vmcore. Non-dumpable
regions are later marked MEMBLOCK_NODUMP;the filtering itself happens
in memblock, keeping the arch kdump code independent of the DT API.
Most reserved regions are owned by devices and do not contain data
useful for kernel crash analysis, so dumpable default to false.
Reusable CMA regions are different: their pages are handed back to the
buddy allocator and may contain key data for crash analysis, so set
dumpable to true in rmem_cma_setup().
The dumpable flag is also used to check /memreserve/ entries for overlap
with other dumpable regions.
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
include/linux/of_reserved_mem.h | 1 +
kernel/dma/contiguous.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index e8b20b29fa68..55a67cee41ea 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -15,6 +15,7 @@ struct reserved_mem {
phys_addr_t base;
phys_addr_t size;
void *priv;
+ bool dumpable;
};
struct reserved_mem_ops {
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index f754079a287d..63ff134dadd4 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -565,6 +565,7 @@ static int __init rmem_cma_setup(unsigned long node, struct reserved_mem *rmem)
dma_contiguous_default_area = cma;
rmem->priv = cma;
+ rmem->dumpable = true;
pr_info("Reserved memory: created CMA memory pool at %pa, size %ld MiB\n",
&rmem->base, (unsigned long)rmem->size / SZ_1M);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 3/8] of: reserved_mem: mark /reserved-memory entries with MEMBLOCK_NODUMP
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
2026-08-06 9:35 ` [PATCH v5 1/8] memblock: introduce MEMBLOCK_NODUMP flag Wandun Chen
2026-08-06 9:35 ` [PATCH v5 2/8] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP Wandun Chen
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Mark non-dumpable reserved-memory regions with MEMBLOCK_NODUMP so
kdump can omit them from the vmcore.
The marking is guarded by CONFIG_CRASH_DUMP so non-kdump kernels do not
pay the cost of splitting memblock.memory entries at NODUMP boundaries.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
drivers/of/of_reserved_mem.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 7b1616b9c6c2..f38d11df6f15 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -674,6 +674,9 @@ static void __init fdt_init_reserved_mem_node(unsigned long node, const char *un
rmem->name ? rmem->name : "unknown");
}
+ if (IS_ENABLED(CONFIG_CRASH_DUMP) && !rmem->dumpable)
+ memblock_mark_nodump(rmem->base, rmem->size);
+
reserved_mem_count++;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (2 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 3/8] of: reserved_mem: mark /reserved-memory entries with MEMBLOCK_NODUMP Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 5/8] riscv: build crash_mem ranges from memblock instead of resource tree Wandun Chen
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
The /memreserve/ entries are memory reservations made by the bootloader
or firmware, their contents are not needed for kernel crash analysis,
so mark them MEMBLOCK_NODUMP to have kdump omit them from the vmcore.
Entries that overlap a dumpable region (such as CMA) are left unmarked,
because the pages of a dumpable region may carry crash-relevant data.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
drivers/of/fdt.c | 2 ++
drivers/of/of_private.h | 1 +
drivers/of/of_reserved_mem.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a64afc3ded3d..2aa888997e9b 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1286,6 +1286,8 @@ void __init unflatten_device_tree(void)
/* Save the statically-placed regions in the reserved_mem array */
fdt_scan_reserved_mem_late();
+ fdt_mark_memreserve_nodump();
+
/* Populate an empty root node when bootloader doesn't provide one */
if (!fdt) {
fdt = (void *) __dtb_empty_root_begin;
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 0ae16da066e2..667ce9e46aab 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -187,6 +187,7 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node *
int fdt_scan_reserved_mem(void);
void __init fdt_scan_reserved_mem_late(void);
+void __init fdt_mark_memreserve_nodump(void);
bool of_fdt_device_is_available(const void *blob, unsigned long node);
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index f38d11df6f15..f0683b5d77b3 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -251,6 +251,38 @@ static void __init __rmem_check_for_overlap(void)
}
}
+void __init fdt_mark_memreserve_nodump(void)
+{
+ u64 base, size;
+ int n;
+ const void *fdt = initial_boot_params;
+
+ if (!IS_ENABLED(CONFIG_CRASH_DUMP))
+ return;
+
+ if (!fdt)
+ return;
+
+ for (n = 0; ; n++) {
+ int i;
+
+ if (fdt_get_mem_rsv(fdt, n, &base, &size))
+ break;
+ if (!size)
+ break;
+
+ for (i = 0; i < reserved_mem_count; i++) {
+ struct reserved_mem *rmem = &reserved_mem[i];
+
+ if (rmem->dumpable && base < rmem->base + rmem->size &&
+ rmem->base < base + size)
+ break;
+ }
+ if (i == reserved_mem_count)
+ memblock_mark_nodump(base, size);
+ }
+}
+
/**
* fdt_scan_reserved_mem_late() - Scan FDT and initialize remaining reserved
* memory regions.
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 5/8] riscv: build crash_mem ranges from memblock instead of resource tree
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (3 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 6/8] crash_core: fold duplicated memblock arch hooks into the weak default Wandun Chen
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Replace walk_system_ram_res() with for_each_mem_range(). The
MEMBLOCK_NODUMP flag lives in memblock, so only by walking memblock
can the reserved-memory regions marked MEMBLOCK_NODUMP be excluded
from the vmcore.
for_each_mem_range() iterates memblock.memory, which is freed after
init unless ARCH_KEEP_MEMBLOCK is selected. riscv needs
ARCH_KEEP_MEMBLOCK to filter reserved memory from the vmcore, so
extend its condition (ACPI || KEXEC) with (KEXEC_FILE &&
CRASH_DUMP). arm64 and loongarch already select ARCH_KEEP_MEMBLOCK
unconditionally.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
arch/riscv/Kconfig | 2 +-
arch/riscv/kernel/machine_kexec_file.c | 31 ++++++++++----------------
2 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index ef1101bec76c..bd8726b4dfbe 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -57,7 +57,7 @@ config RISCV
select ARCH_HAS_UBSAN
select ARCH_HAS_VDSO_ARCH_DATA
select ARCH_HAVE_NMI_SAFE_CMPXCHG
- select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC
+ select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC || (KEXEC_FILE && CRASH_DUMP)
select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
diff --git a/arch/riscv/kernel/machine_kexec_file.c b/arch/riscv/kernel/machine_kexec_file.c
index 26cd2a8bd0cd..808e872f4063 100644
--- a/arch/riscv/kernel/machine_kexec_file.c
+++ b/arch/riscv/kernel/machine_kexec_file.c
@@ -37,39 +37,32 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)
}
#ifdef CONFIG_CRASH_DUMP
-static int get_nr_ram_ranges_callback(struct resource *res, void *arg)
-{
- unsigned int *nr_ranges = arg;
-
- (*nr_ranges)++;
- return 0;
-}
-
unsigned int arch_get_system_nr_ranges(void)
{
unsigned int nr_ranges = 2 + crashk_cma_cnt; /* For exclusion of crashkernel region */
+ u64 i;
+ phys_addr_t start, end;
- walk_system_ram_res(0, -1, &nr_ranges, get_nr_ram_ranges_callback);
+ for_each_mem_range(i, &start, &end)
+ nr_ranges++;
return nr_ranges;
}
-static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg)
+int arch_crash_populate_cmem(struct crash_mem *cmem)
{
- struct crash_mem *cmem = arg;
+ u64 i;
+ phys_addr_t start, end;
- cmem->ranges[cmem->nr_ranges].start = res->start;
- cmem->ranges[cmem->nr_ranges].end = res->end;
- cmem->nr_ranges++;
+ for_each_mem_range(i, &start, &end) {
+ cmem->ranges[cmem->nr_ranges].start = start;
+ cmem->ranges[cmem->nr_ranges].end = end - 1;
+ cmem->nr_ranges++;
+ }
return 0;
}
-int arch_crash_populate_cmem(struct crash_mem *cmem)
-{
- return walk_system_ram_res(0, -1, cmem, prepare_elf64_ram_headers_callback);
-}
-
static char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
unsigned long cmdline_len)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 6/8] crash_core: fold duplicated memblock arch hooks into the weak default
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (4 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 5/8] riscv: build crash_mem ranges from memblock instead of resource tree Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 7/8] crash_core: replace for_each_mem_range() with for_each_mem_region() Wandun Chen
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
The weak defaults are only consumed by crash_prepare_headers(), which is
called only by arm64, riscv, loongarch (via the weak default) and x86
(via its own non-weak override).
arm64, loongarch and riscv open-code the same memblock walk in
arch_get_system_nr_ranges() and arch_crash_populate_cmem(). Move it into
the __weak defaults in kernel/crash_core.c and delete the arch copies.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
arch/arm64/kernel/machine_kexec_file.c | 29 ----------------------
arch/loongarch/kernel/machine_kexec_file.c | 27 --------------------
arch/riscv/kernel/machine_kexec_file.c | 26 -------------------
kernel/crash_core.c | 25 +++++++++++++++++--
4 files changed, 23 insertions(+), 84 deletions(-)
diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 854d872dfd0f..34d944d3f22f 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -14,7 +14,6 @@
#include <linux/kernel.h>
#include <linux/kexec.h>
#include <linux/libfdt.h>
-#include <linux/memblock.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/slab.h>
@@ -39,34 +38,6 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)
return kexec_image_post_load_cleanup_default(image);
}
-#ifdef CONFIG_CRASH_DUMP
-unsigned int arch_get_system_nr_ranges(void)
-{
- unsigned int nr_ranges = 2 + crashk_cma_cnt; /* for exclusion of crashkernel region */
- phys_addr_t start, end;
- u64 i;
-
- for_each_mem_range(i, &start, &end)
- nr_ranges++;
-
- return nr_ranges;
-}
-
-int arch_crash_populate_cmem(struct crash_mem *cmem)
-{
- phys_addr_t start, end;
- u64 i;
-
- for_each_mem_range(i, &start, &end) {
- cmem->ranges[cmem->nr_ranges].start = start;
- cmem->ranges[cmem->nr_ranges].end = end - 1;
- cmem->nr_ranges++;
- }
-
- return 0;
-}
-#endif
-
/*
* Tries to add the initrd and DTB to the image. If it is not possible to find
* valid locations, this function will undo changes to the image and return non
diff --git a/arch/loongarch/kernel/machine_kexec_file.c b/arch/loongarch/kernel/machine_kexec_file.c
index 5412aa9f3568..481b8f906a56 100644
--- a/arch/loongarch/kernel/machine_kexec_file.c
+++ b/arch/loongarch/kernel/machine_kexec_file.c
@@ -13,7 +13,6 @@
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/kexec.h>
-#include <linux/memblock.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/types.h>
@@ -56,32 +55,6 @@ static void cmdline_add_initrd(struct kimage *image, unsigned long *cmdline_tmpl
}
#ifdef CONFIG_CRASH_DUMP
-unsigned int arch_get_system_nr_ranges(void)
-{
- int nr_ranges = 2; /* for exclusion of crashkernel region */
- phys_addr_t start, end;
- uint64_t i;
-
- for_each_mem_range(i, &start, &end)
- nr_ranges++;
-
- return nr_ranges;
-}
-
-int arch_crash_populate_cmem(struct crash_mem *cmem)
-{
- phys_addr_t start, end;
- uint64_t i;
-
- for_each_mem_range(i, &start, &end) {
- cmem->ranges[cmem->nr_ranges].start = start;
- cmem->ranges[cmem->nr_ranges].end = end - 1;
- cmem->nr_ranges++;
- }
-
- return 0;
-}
-
/*
* Add the "mem=size@start" command line parameter to command line, indicating the
* memory region the new kernel can use to boot into.
diff --git a/arch/riscv/kernel/machine_kexec_file.c b/arch/riscv/kernel/machine_kexec_file.c
index 808e872f4063..fdc6695e8588 100644
--- a/arch/riscv/kernel/machine_kexec_file.c
+++ b/arch/riscv/kernel/machine_kexec_file.c
@@ -37,32 +37,6 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)
}
#ifdef CONFIG_CRASH_DUMP
-unsigned int arch_get_system_nr_ranges(void)
-{
- unsigned int nr_ranges = 2 + crashk_cma_cnt; /* For exclusion of crashkernel region */
- u64 i;
- phys_addr_t start, end;
-
- for_each_mem_range(i, &start, &end)
- nr_ranges++;
-
- return nr_ranges;
-}
-
-int arch_crash_populate_cmem(struct crash_mem *cmem)
-{
- u64 i;
- phys_addr_t start, end;
-
- for_each_mem_range(i, &start, &end) {
- cmem->ranges[cmem->nr_ranges].start = start;
- cmem->ranges[cmem->nr_ranges].end = end - 1;
- cmem->nr_ranges++;
- }
-
- return 0;
-}
-
static char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
unsigned long cmdline_len)
{
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 2b36aa9fade0..77285ae3ce60 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -281,8 +281,29 @@ static struct crash_mem *alloc_cmem(unsigned int nr_ranges)
return cmem;
}
-unsigned int __weak arch_get_system_nr_ranges(void) { return 0; }
-int __weak arch_crash_populate_cmem(struct crash_mem *cmem) { return -1; }
+unsigned int __weak arch_get_system_nr_ranges(void)
+{
+ unsigned int nr_ranges = 2 + crashk_cma_cnt; /* crashk_res + crashk_low_res, +CMA splits */
+ phys_addr_t start, end;
+ u64 i;
+
+ for_each_mem_range(i, &start, &end)
+ nr_ranges++;
+ return nr_ranges;
+}
+
+int __weak arch_crash_populate_cmem(struct crash_mem *cmem)
+{
+ phys_addr_t start, end;
+ u64 i;
+
+ for_each_mem_range(i, &start, &end) {
+ cmem->ranges[cmem->nr_ranges].start = start;
+ cmem->ranges[cmem->nr_ranges].end = end - 1;
+ cmem->nr_ranges++;
+ }
+ return 0;
+}
int __weak arch_crash_exclude_ranges(struct crash_mem *cmem) { return 0; }
int __weak arch_crash_exclude_mem_range(struct crash_mem **mem,
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 7/8] crash_core: replace for_each_mem_range() with for_each_mem_region()
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (5 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 6/8] crash_core: fold duplicated memblock arch hooks into the weak default Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 9:35 ` [PATCH v5 8/8] crash_core: skip MEMBLOCK_NODUMP regions when building vmcore ELF header Wandun Chen
2026-08-06 10:11 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Marek Szyprowski
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
for_each_mem_range() skips MEMBLOCK_NOMAP regions implicitly. Switch the
weak defaults to for_each_mem_region(), which exposes struct
memblock_region and per-region flags, and filter NOMAP regions explicitly
via the new crash_should_skip_region() helper. This prepares for a
subsequent patch to extend the skip filter.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
kernel/crash_core.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 77285ae3ce60..fb78b7814f18 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -269,6 +269,12 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
return 0;
}
+/* Exclude NOMAP regions from the vmcore. */
+static bool crash_should_skip_region(struct memblock_region *reg)
+{
+ return memblock_is_nomap(reg);
+}
+
static struct crash_mem *alloc_cmem(unsigned int nr_ranges)
{
struct crash_mem *cmem;
@@ -284,22 +290,25 @@ static struct crash_mem *alloc_cmem(unsigned int nr_ranges)
unsigned int __weak arch_get_system_nr_ranges(void)
{
unsigned int nr_ranges = 2 + crashk_cma_cnt; /* crashk_res + crashk_low_res, +CMA splits */
- phys_addr_t start, end;
- u64 i;
+ struct memblock_region *reg;
- for_each_mem_range(i, &start, &end)
+ for_each_mem_region(reg) {
+ if (crash_should_skip_region(reg))
+ continue;
nr_ranges++;
+ }
return nr_ranges;
}
int __weak arch_crash_populate_cmem(struct crash_mem *cmem)
{
- phys_addr_t start, end;
- u64 i;
+ struct memblock_region *reg;
- for_each_mem_range(i, &start, &end) {
- cmem->ranges[cmem->nr_ranges].start = start;
- cmem->ranges[cmem->nr_ranges].end = end - 1;
+ for_each_mem_region(reg) {
+ if (crash_should_skip_region(reg))
+ continue;
+ cmem->ranges[cmem->nr_ranges].start = reg->base;
+ cmem->ranges[cmem->nr_ranges].end = reg->base + reg->size - 1;
cmem->nr_ranges++;
}
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5 8/8] crash_core: skip MEMBLOCK_NODUMP regions when building vmcore ELF header
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (6 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 7/8] crash_core: replace for_each_mem_range() with for_each_mem_region() Wandun Chen
@ 2026-08-06 9:35 ` Wandun Chen
2026-08-06 10:11 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Marek Szyprowski
8 siblings, 0 replies; 10+ messages in thread
From: Wandun Chen @ 2026-08-06 9:35 UTC (permalink / raw)
To: catalin.marinas, will, chenhuacai, pjw, palmer, aou, robh,
saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
m.szyprowski, linux-arm-kernel, linux-kernel, loongarch,
linux-riscv, devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Reserve regions (for GPU, DSP, ...) carry no data useful for crash
analysis. Exclude MEMBLOCK_NODUMP regions from the vmcore ELF header to
reduce vmcore size and capture time. crash_should_skip_region() now also
returns true for MEMBLOCK_NODUMP.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
kernel/crash_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index fb78b7814f18..8cc9d666bc54 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -269,10 +269,10 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
return 0;
}
-/* Exclude NOMAP regions from the vmcore. */
+/* Exclude NOMAP and NODUMP regions from the vmcore. */
static bool crash_should_skip_region(struct memblock_region *reg)
{
- return memblock_is_nomap(reg);
+ return memblock_is_nomap(reg) || memblock_is_nodump(reg);
}
static struct crash_mem *alloc_cmem(unsigned int nr_ranges)
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v5 0/8] kdump: reduce vmcore size and capture time
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
` (7 preceding siblings ...)
2026-08-06 9:35 ` [PATCH v5 8/8] crash_core: skip MEMBLOCK_NODUMP regions when building vmcore ELF header Wandun Chen
@ 2026-08-06 10:11 ` Marek Szyprowski
8 siblings, 0 replies; 10+ messages in thread
From: Marek Szyprowski @ 2026-08-06 10:11 UTC (permalink / raw)
To: Wandun Chen, catalin.marinas, will, chenhuacai, pjw, palmer, aou,
robh, saravanak, rppt, baoquan.he, pasha.tatashin, pratyush,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, linux-mm, kexec, iommu
Cc: kernel, alex, akpm, ruirui.yang, robin.murphy
On 06.08.2026 11:35, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@lixiang.com>
>
> On SoCs that carve out large firmware-owned reserved memory (GPU,
> camera ISP, ...), kdump currently dumps those carveouts as part of
> system RAM even though their contents are firmware state that is not
> useful for kernel crash analysis.
>
> This series introduces a 'dumpable' flag on struct reserved_mem and a
> MEMBLOCK_NODUMP flag in memblock to filter vmcore ELF header on DT-based
> architectures (arm64, riscv, loongarch). Reserved regions default to
> non-dumpable and are marked MEMBLOCK_NODUMP so kdump omits them;
> reusable CMA regions are explicitly marked dumpable in rmem_cma_setup()
> because their pages are handed back to the buddy allocator and may carry
> crash-relevant data.
>
> Since the reserved memory regions are filtered out, the vmcore is
> smaller in size and faster to produce. ACPI systems already filter
> reserved memory out of the vmcore through their existing path; only
> DT-based systems currently fail to filter these regions, which is what
> this series addresses. The flag lives in memblock itself rather than
> in a DT-only structure, so the mechanism is generic and both ACPI and
> DT systems can benefit from it (suggested by Rob, thanks).
>
> The series is based on linux-next and is organized as follows:
> Patches 1-2: Introduce MEMBLOCK_NODUMP in memblock and the dumpable
> flag on struct reserved_mem.
> Patches 3-4: Mark non-dumpable /reserved-memory and /memreserve/
> entries with MEMBLOCK_NODUMP.
> Patch 5: Switch riscv to memblock so the NODUMP flag is visible
> to the vmcore ELF header builder; add (KEXEC_FILE &&
> CRASH_DUMP) to riscv's ARCH_KEEP_MEMBLOCK condition.
> Patches 6-8: Fold the duplicated per-arch memblock walks into the
> weak defaults in crash_core, switch to
> for_each_mem_region(), and exclude MEMBLOCK_NODUMP
> regions from the vmcore ELF header.
>
> v4 --> v5:
> 1. Rework the mechanism around a memblock-level MEMBLOCK_NODUMP flag
> (suggested by Rob) instead of the v4 opt-in 'dumpable' flag on
> DT-only struct reserved_mem.
>
> 2. Switch the riscv vmcore elf header preparation to use memblock
> instead of the resource tree, aligning it with arm64 and loongarch,
> so riscv also can exclude reserved memory from vmcore.
>
> 3. Deduplicate the vmcore elf header preparation: arm64, riscv and
> loongarch open-coded the same logic, so fold it into shared
> __weak defaults in crash_core.
>
> 4. Drop the v4 patch that saved /memreserve/ entries into the
> reserved_mem array; /memreserve/ is now marked MEMBLOCK_NODUMP
> directly.
v5 looks much better, at least from the reserved memory regions perspective.
> v3 --> v4:
> 1. Rebase this series on v7.2-rc1.
> 2. Add two cleanup patches (patch 02/03).
> 3. Simplify patch 03 to avoid checking whether initial_boot_params is
> NULL multiple times, suggested by Rob.
>
> v2 --> v3:
> 1. Fix out-of-bounds issue if device tree lacks /reserved-memory node.[2]
> 2. Fix UAF issue when alloc_reserved_mem_array() fails.
> 3. Add some prepare patches.
>
> v1 --> v2:
> 1. v1 added an opt-out DT property ('linux,no-dump'). Per Rob's
> feedback [1], v2 drop that property and exclude reserve memory
> by default.
> 2. Split some prepared patches from the original patches.
> 3. Address coding-style comments on patch 5 from Rob.
>
> [1] https://lore.kernel.org/lkml/20260506144542.GA2072596-robh@kernel.org/
> [2] https://protect2.fireeye.com/v1/url?k=05b72ed7-643c3bed-05b6a598-74fe4860008a-295907342918bd15&q=1&e=c408484d-fdd8-4fe4-8eee-690e883afb73&u=https%3A%2F%2Fsashiko.dev%2F%23%2Fpatchset%2F20260520091844.592753-1-chenwandun%2540lixiang.com%3Fpart%3D4
>
> Wandun Chen (8):
> memblock: introduce MEMBLOCK_NODUMP flag
> of: reserved_mem: add dumpable flag to opt-in vmcore
> of: reserved_mem: mark /reserved-memory entries with MEMBLOCK_NODUMP
> of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP
> riscv: build crash_mem ranges from memblock instead of resource tree
> crash_core: fold duplicated memblock arch hooks into the weak default
> crash_core: replace for_each_mem_range() with for_each_mem_region()
> crash_core: skip MEMBLOCK_NODUMP regions when building vmcore ELF
> header
>
> arch/arm64/kernel/machine_kexec_file.c | 29 ------------------
> arch/loongarch/kernel/machine_kexec_file.c | 27 -----------------
> arch/riscv/Kconfig | 2 +-
> arch/riscv/kernel/machine_kexec_file.c | 33 --------------------
> drivers/of/fdt.c | 2 ++
> drivers/of/of_private.h | 1 +
> drivers/of/of_reserved_mem.c | 35 ++++++++++++++++++++++
> include/linux/memblock.h | 9 ++++++
> include/linux/of_reserved_mem.h | 1 +
> kernel/crash_core.c | 34 +++++++++++++++++++--
> kernel/dma/contiguous.c | 1 +
> mm/memblock.c | 16 ++++++++++
> 12 files changed, 98 insertions(+), 92 deletions(-)
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 10+ messages in thread