Re: [PATCH] kdump: Give crashkernel CMA areas unique names

From: Usama Arif

Date: Fri Nov 06 2026 - 08:58:27 EST


On Fri, 6 Nov 2026 11:43:09 +0100 Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx> wrote:

> reserve_crashkernel_cma() names every CMA area it reserves
> "crashkernel". If the requested size can't be reserved in one piece,
> it falls back to several smaller areas, all with the same name.
> With CONFIG_CMA_SYSFS, cma_sysfs_init() then fails to create the second
> directory:
>
> sysfs: cannot create duplicate filename '/kernel/mm/cma/crashkernel'
>
> and the error path removes the sysfs entries of all CMA areas.
>
> With CONFIG_CMA_DEBUGFS, debugfs refuses the duplicate directories as
> well:
>
> debugfs: 'crashkernel' already exists in 'cma'
>
> so only the first area shows up in debugfs.
>
> Keep the name of the first area and add the index to the others:
> crashkernel, crashkernel1, crashkernel2, ...
>
> Fixes: ab475510e042 ("kdump: implement reserve_crashkernel_cma")
> Signed-off-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
> ---
> Found while adding crashkernel CMA support for s390.
>
> kernel/crash_reserve.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)

Thanks for the fix and pointing me to it in [1]!

Acked-by: Usama Arif <usama.arif@xxxxxxxxx>

[1] https://lore.kernel.org/all/20261106104309.3669583-1-zaslonko@xxxxxxxxxxxxx/

>
> diff --git a/kernel/crash_reserve.c b/kernel/crash_reserve.c
> index eee37a11380c..e58318b1e092 100644
> --- a/kernel/crash_reserve.c
> +++ b/kernel/crash_reserve.c
> @@ -483,10 +483,16 @@ void __init reserve_crashkernel_cma(unsigned long long cma_size)
> while (cma_size > reserved_size &&
> crashk_cma_cnt < CRASHKERNEL_CMA_RANGES_MAX) {
>
> + char name[CMA_MAX_NAME];
> struct cma *res;
>
> + /* CMA area names show up in sysfs and debugfs, keep them unique */
> + if (crashk_cma_cnt)
> + snprintf(name, sizeof(name), "crashkernel%d", crashk_cma_cnt);
> + else
> + strscpy(name, "crashkernel");
> if (cma_declare_contiguous(0, request_size, 0, 0, 0, false,
> - "crashkernel", &res)) {
> + name, &res)) {
> /* reservation failed, try half-sized blocks */
> if (request_size <= PAGE_SIZE)
> break;
>
> base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1
> --
> 2.55.0
>
>