Re: [PATCH v6 05/10] crash_core: replace for_each_mem_range() with for_each_mem_region()
From: Baoquan He
Date: Fri Sep 18 2026 - 04:09:05 EST
On 09/02/26 at 03:31pm, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@xxxxxxxxxxx>
>
> 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@xxxxxxxxxxx>
> Tested-by: Meijing Zhao <zhaomeijing@xxxxxxxxxxx>
> ---
> kernel/crash_core.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
Acked-by: Baoquan He <baoquan.he@xxxxxxxxx>
>
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index 3adee1ae120c..bd64cf585795 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -270,6 +270,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;
> @@ -285,22 +291,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
>