Skip to contentSkip to conversation

kdump: Give crashkernel CMA areas unique names

PATCH Applied Mikhail Zaslonko 5 participants 5 messages Nov 6 – Nov 7

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kdump: Give crashkernel CMA areas unique names

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

---
Found while adding crashkernel CMA support for s390.

 kernel/crash_reserve.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/crash_reserve.c +7 -1
index eee37a11380c..e58318b1e092 100644
@@ -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

Signature · 1 line
2.55.0
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Mikhail Zaslonko

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'

Quoted 8 lines

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

---

Signature · 3 lines
Cheers,

David
Acked-by on v1 1/1
#2 lore raw
In reply to Mikhail Zaslonko
Quoted 20 lines · On Fri, 6 Nov 2026 11:43:09 +0100 Mikhail Zaslonko <[email protected]>…

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

Quoted 7 lines
Fixes ab475510e042 ("kdump: implement reserve_crashkernel_cma")

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

[1] https://lore.kernel.org/all/[email protected]/

Quoted 29 lines
kernel/crash_reserve.c +7 -1
index eee37a11380c..e58318b1e092 100644
@@ -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

Signature · 1 line
2.55.0
Acked-by on v1 1/1
#3 lore raw
In reply to Mikhail Zaslonko
Quoted 15 lines · Mikhail Zaslonko

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'

Quoted 7 lines

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

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.

Signature · 2 lines
Jiri Bohac <[email protected]>
SUSE Labs, Prague, Czechia
maintainer Applied
#4 lore raw
In reply to Mikhail Zaslonko

From: Mike Rapoport (Microsoft) <[email protected]>

Quoted 9 lines · Mikhail Zaslonko

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'

[...]

Applied to kexec-next branch of liveupdate/linux.git tree, thanks!

[1/1] kdump: Give crashkernel CMA areas unique names

      commit: 941aef93e9e1df74f0ef0fa8653c435613131243

tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: kexec-next

--
Sincerely yours,
Mike.