[PATCH v5 1/4] powerpc/crash: sort crash memory ranges before preparing elfcorehdr

Mike Rapoport rppt at kernel.org
Thu Feb 12 06:43:38 PST 2026


On Thu, Feb 12, 2026 at 06:09:58PM +0800, Jinjie Ruan wrote:
> From: Sourabh Jain <sourabhjain at linux.ibm.com>
> 
> During a memory hot-remove event, the elfcorehdr is rebuilt to exclude
> the removed memory. While updating the crash memory ranges for this
> operation, the crash memory ranges array can become unsorted. This
> happens because remove_mem_range() may split a memory range into two
> parts and append the higher-address part as a separate range at the end
> of the array.
> 
> So far, no issues have been observed due to the unsorted crash memory
> ranges. However, this could lead to problems once crash memory range
> removal is handled by generic code, as introduced in the upcoming
> patches in this series.
> 
> Currently, powerpc uses a platform-specific function,
> remove_mem_range(), to exclude hot-removed memory from the crash memory
> ranges. This function performs the same task as the generic
> crash_exclude_mem_range() in crash_core.c. The generic helper also
> ensures that the crash memory ranges remain sorted. So remove the
> redundant powerpc-specific implementation and instead call
> crash_exclude_mem_range_guarded() (which internally calls
> crash_exclude_mem_range()) to exclude the hot-removed memory ranges.
> 
> Cc: Andrew Morton <akpm at linux-foundation.org>
> Cc: Baoquan he <bhe at redhat.com>
> Cc: Jinjie Ruan <ruanjinjie at huawei.com>
> Cc: Hari Bathini <hbathini at linux.ibm.com>
> Cc: Madhavan Srinivasan <maddy at linux.ibm.com>
> Cc: Mahesh Salgaonkar <mahesh at linux.ibm.com>
> Cc: Michael Ellerman <mpe at ellerman.id.au>
> Cc: Ritesh Harjani (IBM) <ritesh.list at gmail.com>
> Cc: Shivang Upadhyay <shivangu at linux.ibm.com>
> Cc: linux-kernel at vger.kernel.org
> Signed-off-by: Sourabh Jain <sourabhjain at linux.ibm.com>
> ---
>  arch/powerpc/include/asm/kexec_ranges.h |  4 +-
>  arch/powerpc/kexec/crash.c              |  5 +-
>  arch/powerpc/kexec/ranges.c             | 87 +------------------------
>  3 files changed, 7 insertions(+), 89 deletions(-)

This looks like a nice improvement!
FWIW

Acked-by: Mike Rapoport (Microsoft) <rppt at kernel.org>

-- 
Sincerely yours,
Mike.



More information about the linux-riscv mailing list