mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kdump: Give crashkernel CMA areas unique names
@ 2026-11-06 10:43 Mikhail Zaslonko
  2026-11-06 12:38 ` David Hildenbrand (Arm)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mikhail Zaslonko @ 2026-11-06 10:43 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He
  Cc: Mike Rapoport, Pasha Tatashin, Pratyush Yadav, Dave Young,
	Jiri Bohac, David Hildenbrand, Usama Arif, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, kexec, linux-mm, linux-kernel

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@linux.ibm.com>
---
Found while adding crashkernel CMA support for s390.

 kernel/crash_reserve.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kdump: Give crashkernel CMA areas unique names
  2026-11-06 10:43 [PATCH] kdump: Give crashkernel CMA areas unique names Mikhail Zaslonko
@ 2026-11-06 12:38 ` David Hildenbrand (Arm)
  2026-11-06 13:50 ` Usama Arif
  2026-11-06 14:13 ` Jiri Bohac
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-06 12:38 UTC (permalink / raw)
  To: Mikhail Zaslonko, Andrew Morton, Baoquan He
  Cc: Mike Rapoport, Pasha Tatashin, Pratyush Yadav, Dave Young,
	Jiri Bohac, Usama Arif, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, kexec, linux-mm, linux-kernel

On 11/6/26 11:43, Mikhail Zaslonko 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@linux.ibm.com>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kdump: Give crashkernel CMA areas unique names
  2026-11-06 10:43 [PATCH] kdump: Give crashkernel CMA areas unique names Mikhail Zaslonko
  2026-11-06 12:38 ` David Hildenbrand (Arm)
@ 2026-11-06 13:50 ` Usama Arif
  2026-11-06 14:13 ` Jiri Bohac
  2 siblings, 0 replies; 4+ messages in thread
From: Usama Arif @ 2026-11-06 13:50 UTC (permalink / raw)
  To: Mikhail Zaslonko
  Cc: Usama Arif, Andrew Morton, Baoquan He, Mike Rapoport,
	Pasha Tatashin, Pratyush Yadav, Dave Young, Jiri Bohac,
	David Hildenbrand, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, kexec, linux-mm, linux-kernel

On Fri,  6 Nov 2026 11:43:09 +0100 Mikhail Zaslonko <zaslonko@linux.ibm.com> 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@linux.ibm.com>
> ---
> 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@linux.dev>

[1] https://lore.kernel.org/all/20261106104309.3669583-1-zaslonko@linux.ibm.com/

> 
> 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
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kdump: Give crashkernel CMA areas unique names
  2026-11-06 10:43 [PATCH] kdump: Give crashkernel CMA areas unique names Mikhail Zaslonko
  2026-11-06 12:38 ` David Hildenbrand (Arm)
  2026-11-06 13:50 ` Usama Arif
@ 2026-11-06 14:13 ` Jiri Bohac
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Bohac @ 2026-11-06 14:13 UTC (permalink / raw)
  To: Mikhail Zaslonko
  Cc: Andrew Morton, Baoquan He, Mike Rapoport, Pasha Tatashin,
	Pratyush Yadav, Dave Young, David Hildenbrand, Usama Arif,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, kexec,
	linux-mm, linux-kernel

On Fri, Nov 06, 2026 at 11:43:09AM +0100, Mikhail Zaslonko 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@linux.ibm.com>

Thanks for fixing this.

I don't think we really need the special case for crashk_cma_cnt == 0 
and that "crashkernel0" would be fine. But I don't mind either way.

Acked-by: Jiri Bohac <jbohac@suse.cz>

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, Prague, Czechia


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-06 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 10:43 [PATCH] kdump: Give crashkernel CMA areas unique names Mikhail Zaslonko
2026-11-06 12:38 ` David Hildenbrand (Arm)
2026-11-06 13:50 ` Usama Arif
2026-11-06 14:13 ` Jiri Bohac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®