mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
Commit35c18f2933("Add a new optional ",cma" suffix to the crashkernel= command line option") and commitab475510e0("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. Tested-by: Breno Leitao <[email protected]> Acked-by: Catalin Marinas <[email protected]> Acked-by: Rob Herring (Arm) <[email protected]> Acked-by: Baoquan He <[email protected]> Acked-by: Mike Rapoport (Microsoft) <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Signed-off-by: Jinjie Ruan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
69 lines
1.9 KiB
C
69 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef LINUX_CRASH_RESERVE_H
|
|
#define LINUX_CRASH_RESERVE_H
|
|
|
|
#include <linux/linkage.h>
|
|
#include <linux/elfcore.h>
|
|
#include <linux/elf.h>
|
|
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
|
|
#include <asm/crash_reserve.h>
|
|
#endif
|
|
|
|
/* Location of a reserved region to hold the crash kernel.
|
|
*/
|
|
extern struct resource crashk_res;
|
|
extern struct resource crashk_low_res;
|
|
extern struct range crashk_cma_ranges[];
|
|
|
|
#define CRASHK_CMA_RANGES_MAX 4
|
|
#if defined(CONFIG_CMA) && defined(CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION)
|
|
#define CRASHKERNEL_CMA
|
|
#define CRASHKERNEL_CMA_RANGES_MAX (CRASHK_CMA_RANGES_MAX)
|
|
extern int crashk_cma_cnt;
|
|
#else
|
|
#define crashk_cma_cnt 0
|
|
#define CRASHKERNEL_CMA_RANGES_MAX 0
|
|
#endif
|
|
|
|
|
|
int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
|
|
unsigned long long *crash_size, unsigned long long *crash_base,
|
|
unsigned long long *low_size, unsigned long long *cma_size,
|
|
bool *high);
|
|
|
|
void __init reserve_crashkernel_cma(unsigned long long cma_size);
|
|
|
|
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
|
|
#ifndef arch_add_crash_res_to_iomem
|
|
static inline bool arch_add_crash_res_to_iomem(void)
|
|
{
|
|
return true;
|
|
}
|
|
#endif
|
|
#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE
|
|
#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)
|
|
#endif
|
|
#ifndef CRASH_ALIGN
|
|
#define CRASH_ALIGN SZ_2M
|
|
#endif
|
|
#ifndef CRASH_ADDR_LOW_MAX
|
|
#define CRASH_ADDR_LOW_MAX SZ_4G
|
|
#endif
|
|
#ifndef CRASH_ADDR_HIGH_MAX
|
|
#define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM()
|
|
#endif
|
|
|
|
void __init reserve_crashkernel_generic(unsigned long long crash_size,
|
|
unsigned long long crash_base,
|
|
unsigned long long crash_low_size,
|
|
bool high);
|
|
#else
|
|
static inline void __init reserve_crashkernel_generic(
|
|
unsigned long long crash_size,
|
|
unsigned long long crash_base,
|
|
unsigned long long crash_low_size,
|
|
bool high)
|
|
{}
|
|
#endif
|
|
#endif /* LINUX_CRASH_RESERVE_H */
|