Skip to content

Comments

[PW_SID:1057091] arm64/riscv: Add support for crashkernel CMA reservation#1490

Open
linux-riscv-bot wants to merge 5 commits intoworkflowfrom
pw1057091
Open

[PW_SID:1057091] arm64/riscv: Add support for crashkernel CMA reservation#1490
linux-riscv-bot wants to merge 5 commits intoworkflowfrom
pw1057091

Conversation

@linux-riscv-bot
Copy link

PR for series 1057091 applied to workflow

Name: arm64/riscv: Add support for crashkernel CMA reservation
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1057091
Version: 6

sourabhjains and others added 5 commits February 24, 2026 09:50
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@linux-foundation.org>
Cc: Baoquan he <bhe@redhat.com>
Cc: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The crash memory alloc, and the exclude of crashk_res, crashk_low_res
and crashk_cma memory are almost identical across different architectures,
handling them in the crash core would eliminate a lot of duplication, so
do them in the common code.

To achieve the above goal, three architecture-specific functions are
introduced:

- arch_get_system_nr_ranges(). Pre-counts the max number of memory ranges.

- arch_crash_populate_cmem(). Collects the memory ranges and fills them
  into cmem.

- arch_crash_exclude_ranges(). Architecture's additional crash memory
  ranges exclusion, defaulting to empty.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The crash memory exclude of crashk_res and crashk_cma memory on powerpc
are almost identical to the generic crash_exclude_core_ranges().

By introducing the architecture-specific arch_crash_exclude_mem_range()
function with a default implementation of crash_exclude_mem_range(),
and using crash_exclude_mem_range_guarded as powerpc's separate
implementation, the generic crash_exclude_core_ranges() helper function
can be reused.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Commit 35c18f2 ("Add a new optional ",cma" suffix to the
crashkernel= command line option") and commit ab47551 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump
crashkernel reservation.

Crash kernel memory reservation wastes production resources if too
large, risks kdump failure if too small, and faces allocation difficulties
on fragmented systems due to contiguous block constraints. The new
CMA-based crashkernel reservation scheme splits the "large fixed
reservation" into a "small fixed region + large CMA dynamic region": the
CMA memory is available to userspace during normal operation to avoid
waste, and is reclaimed for kdump upon crash—saving memory while
improving reliability.

So extend crashkernel CMA reservation support to arm64. The following
changes are made to enable CMA reservation:

- Parse and obtain the CMA reservation size along with other crashkernel
  parameters.
- Call reserve_crashkernel_cma() to allocate the CMA region for kdump.
- Include the CMA-reserved ranges for kdump kernel to use.
- Exclude the CMA-reserved ranges from the crash kernel memory to
  prevent them from being exported through /proc/vmcore, which is already
  done in the crash core.

Update kernel-parameters.txt to document CMA support for crashkernel on
arm64 architecture.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Commit 35c18f2 ("Add a new optional ",cma" suffix to the
crashkernel= command line option") and commit ab47551 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump
crashkernel reservation. This allows the kernel to dynamically allocate
contiguous memory for crash dumping when needed, rather than permanently
reserving a fixed region at boot time.

So extend crashkernel CMA reservation support to riscv. The following
changes are made to enable CMA reservation:

- Parse and obtain the CMA reservation size along with other crashkernel
  parameters.
- Call reserve_crashkernel_cma() to allocate the CMA region for kdump.
- Include the CMA-reserved ranges for kdump kernel to use.
- Exclude the CMA-reserved ranges from the crash kernel memory to
  prevent them from being exported through /proc/vmcore, which is already
  done in the crash core.

Update kernel-parameters.txt to document CMA support for crashkernel on
riscv architecture.

Acked-by: Paul Walmsley <pjw@kernel.org> # arch/riscv
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.83 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1000.18 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1350.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.09 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.17 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#95: FILE: arch/powerpc/kexec/ranges.c:557:
+int crash_exclude_mem_range_guarded(struct crash_mem **mem_ranges,
 					   unsigned long long mstart,

total: 0 errors, 0 warnings, 1 checks, 124 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 49fcf70e5313 ("powerpc/crash: sort crash memory ranges before preparing elfcorehdr") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 1 checks, 124 lines checked
CHECK: Alignment should match open parenthesis


@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.39 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
kdoc
Desc: Detects for kdoc errors
Duration: 0.79 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v6,1/5] powerpc/crash: sort crash memory ranges before preparing elfcorehdr"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 137.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1148.10 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1682.74 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 24.48 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 25.92 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.90 seconds
Result: WARNING
Output:

CHECK: Prefer kernel type 'u64' over 'uint64_t'
#121: FILE: arch/loongarch/kernel/machine_kexec_file.c:63:
+	uint64_t i;

CHECK: Prefer kernel type 'u64' over 'uint64_t'
#136: FILE: arch/loongarch/kernel/machine_kexec_file.c:74:
+	uint64_t i;

CHECK: extern prototypes should be avoided in .h files
#383: FILE: include/linux/crash_core.h:69:
+extern int crash_prepare_headers(int need_kernel_map, void **addr,

CHECK: extern prototypes should be avoided in .h files
#392: FILE: include/linux/crash_core.h:88:
+extern unsigned int arch_get_system_nr_ranges(void);

CHECK: extern prototypes should be avoided in .h files
#393: FILE: include/linux/crash_core.h:89:
+extern int arch_crash_populate_cmem(struct crash_mem *cmem);

CHECK: extern prototypes should be avoided in .h files
#394: FILE: include/linux/crash_core.h:90:
+extern int arch_crash_exclude_ranges(struct crash_mem *cmem);

total: 0 errors, 0 warnings, 6 checks, 423 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 5fdaf2170399 ("crash: Exclude crash kernel memory in crash core") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 6 checks, 423 lines checked
CHECK: Prefer kernel type 'u64' over 'uint64_t'
CHECK: extern prototypes should be avoided in .h files


@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v6,2/5] crash: Exclude crash kernel memory in crash core"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.60 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
kdoc
Desc: Detects for kdoc errors
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 3: "[v6,3/5] crash: Use crash_exclude_core_ranges() on powerpc"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 135.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1000.14 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1346.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 24.56 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.51 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 4: "[v6,4/5] arm64: kexec: Add support for crashkernel CMA reservation"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 135.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1117.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1628.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 85.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
module-param
Desc: Detect module_param changes
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 5: "[v6,5/5] riscv: kexec: Add support for crashkernel CMA reservation"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants