mm/cma: Remove CONFIG_CMA_SYSFS option
Subsystems (4)
PATCH 1/1 mm/cma: Remove CONFIG_CMA_SYSFS option
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
---
As discussed with David:
https://lkml.org/lkml/2025/8/6/371
arch/loongarch/configs/loongson3_defconfig | 1 - arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - mm/Kconfig | 7 ------- mm/Makefile | 4 +++- mm/cma.h | 4 ++-- 6 files changed, 5 insertions(+), 13 deletions(-)
arch/loongarch/configs/loongson3_defconfig +0 -1
@@ -120,7 +120,6 @@ CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_CMA=y -CONFIG_CMA_SYSFS=y CONFIG_USERFAULTFD=y CONFIG_NET=y CONFIG_PACKET=y
arch/s390/configs/debug_defconfig +0 -1
@@ -103,7 +103,6 @@ CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_CMA_DEBUGFS=y -CONFIG_CMA_SYSFS=y CONFIG_CMA_AREAS=7 CONFIG_MEM_SOFT_DIRTY=y CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
arch/s390/configs/defconfig +0 -1
@@ -95,7 +95,6 @@ CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y -CONFIG_CMA_SYSFS=y CONFIG_CMA_AREAS=7 CONFIG_MEM_SOFT_DIRTY=y CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
mm/Makefile +3 -1
@@ -119,6 +119,9 @@ obj-$(CONFIG_ZPOOL) += zpool.o obj-$(CONFIG_ZSMALLOC) += zsmalloc.o obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o obj-$(CONFIG_CMA) += cma.o +ifdef CONFIG_SYSFS +obj-$(CONFIG_CMA) += cma_sysfs.o +endif obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_NUMA_MEMBLKS) += numa_memblks.o obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
@@ -127,7 +130,6 @@ obj-$(CONFIG_PAGE_EXTENSION) += page_ext obj-$(CONFIG_PAGE_TABLE_CHECK) += page_table_check.o obj-$(CONFIG_CMA_DEBUGFS) += cma_debug.o obj-$(CONFIG_SECRETMEM) += secretmem.o -obj-$(CONFIG_CMA_SYSFS) += cma_sysfs.o obj-$(CONFIG_USERFAULTFD) += userfaultfd.o obj-$(CONFIG_IDLE_PAGE_TRACKING) += page_idle.o obj-$(CONFIG_DEBUG_PAGEALLOC) += debug_page_alloc.o
mm/cma.h +2 -2
@@ -49,7 +49,7 @@ struct cma {char name[CMA_MAX_NAME ];int nranges;struct cma_memrange ranges[CMA_MAX_RANGES ]; -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS /* the number of CMA page successful allocations */ atomic64_t nr_pages_succeeded;/* the number of CMA page allocation failures */
@@ -80,7 +80,7 @@ static inline unsigned long cma_bitmap_mreturn cmr->count >> cma->order_per_bit; } -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS void cma_sysfs_account_success_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_fail_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_release_pages (struct cma *cma,unsigned long nr_pages);
mm/Kconfig +0 -7
@@ -981,13 +981,6 @@ config CMA_DEBUGFS help Turns on the DebugFS interface for CMA. -config CMA_SYSFS - bool "CMA information through sysfs interface" - depends on CMA && SYSFS - help - This option exposes some sysfs attributes to get information - from CMA. - config CMA_AREAS int "Maximum count of the CMA areas" depends on CMA
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 8 lines · Jean Delvare
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Signed-off-by Jean Delvare <[email protected]>---
As discussed with David:https://lkml.org/lkml/2025/8/6/371
Thanks for the reminder, it sounded familiar but I couldn't remember when this was discussed.
Hoping this was properly compile-tested :)
Signature · 3 lines
Cheers David
Quoted 10 lines · David Hildenbrand (Red Hat)
Quoted 8 lines · Jean Delvare
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Signed-off-by Jean Delvare <[email protected]>---
As discussed with David:https://lkml.org/lkml/2025/8/6/371
Quoted 4 lines
Thanks for the reminder, it sounded familiar but I couldn't remember when this was discussed.
Hoping this was properly compile-tested :)
Yes of course, I build-tested with both CONFIG_SYSFS=y and CONFIG_SYSFS disabled.
Quoted 1 line
Thanks,
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 3 lines · On Thu, 13 Nov 2025 14:56:36 +0100 Jean Delvare <[email protected]> wrote:
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Overall change looks good to me. I have a question below, though.
Quoted 16 lines
Signed-off-by Jean Delvare <[email protected]>---
As discussed with David:
https://lkml.org/lkml/2025/8/6/371arch/loongarch/configs/loongson3_defconfig | 1 - arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - mm/Kconfig | 7 ------- mm/Makefile | 4 +++- mm/cma.h | 4 ++-- 6 files changed, 5 insertions(+), 13 deletions(-)arch/loongarch/configs/loongson3_defconfig +0
-0
[...]
Quoted 12 lines
mm/cma.h +1
-1@@ -49,7 +49,7 @@ struct cma {char name[CMA_MAX_NAME ];int nranges;struct cma_memrange ranges[CMA_MAX_RANGES ]; -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS /* the number of CMA page successful allocations */ atomic64_t nr_pages_succeeded;/* the number of CMA page allocation failures */
mm/cma.h static inline unsigned long cma_bitmap_m · line 86
Quoted 8 lines
mm/cma.h +1
-1@@ -80,7 +80,7 @@ static inline unsigned long cma_bitmap_mreturn cmr->count >> cma->order_per_bit; } -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS void cma_sysfs_account_success_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_fail_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_release_pages (struct cma *cma,unsigned long nr_pages);
Why don't you check CONFIG_CMA together? I think that makes the change more complete and safe.
I found there is no file that can be compiled without CONFIG_CMA but still including this header file, so I expect no real issue for now, though.
Thanks,
SJ
[...]
Hi Seong Jae,
Quoted 49 lines · SeongJae Park
Quoted 3 lines · On Thu, 13 Nov 2025 14:56:36 +0100 Jean Delvare <[email protected]> wrote:
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Overall change looks good to me. I have a question below, though.
Quoted 16 lines
Signed-off-by Jean Delvare <[email protected]>---
As discussed with David:
https://lkml.org/lkml/2025/8/6/371arch/loongarch/configs/loongson3_defconfig | 1 - arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - mm/Kconfig | 7 ------- mm/Makefile | 4 +++- mm/cma.h | 4 ++-- 6 files changed, 5 insertions(+), 13 deletions(-)arch/loongarch/configs/loongson3_defconfig +0
-0[...]
Quoted 12 lines
mm/cma.h +1
-1@@ -49,7 +49,7 @@ struct cma {char name[CMA_MAX_NAME ];int nranges;struct cma_memrange ranges[CMA_MAX_RANGES ]; -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS /* the number of CMA page successful allocations */ atomic64_t nr_pages_succeeded;/* the number of CMA page allocation failures */ mm/cma.h static inline unsigned long cma_bitmap_m · line 86
Quoted 8 lines
mm/cma.h +1
-1@@ -80,7 +80,7 @@ static inline unsigned long cma_bitmap_mreturn cmr->count >> cma->order_per_bit; } -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS void cma_sysfs_account_success_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_fail_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_release_pages (struct cma *cma,unsigned long nr_pages);Why don't you check
CONFIG_CMAtogether? I think that makes the change more complete and safe.
Quoted 2 lines
I found there is no file that can be compiled without
CONFIG_CMAbut still including this header file, so I expect no real issue for now, though.
This would actually make no difference. This header file is internal and not expected to be included by any file besides that CMA core itself, so it is assumed that CONFIG_CMA=y whenever this header file is used. If not, then things would break already, even without my proposed changes (due to cma_areas and cma_area_count being declared but never defined).
Signature · 2 lines
Jean Delvare SUSE L3 Support
SeongJae Park
Reviewed-byQuoted 55 lines · On Fri, 14 Nov 2025 09:48:14 +0100 Jean Delvare <[email protected]> wrote:
Hi Seong Jae,
Quoted 49 lines · SeongJae Park
Quoted 3 lines · On Thu, 13 Nov 2025 14:56:36 +0100 Jean Delvare <[email protected]> wrote:
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Overall change looks good to me. I have a question below, though.
Quoted 16 lines
Signed-off-by Jean Delvare <[email protected]>---
As discussed with David:
https://lkml.org/lkml/2025/8/6/371arch/loongarch/configs/loongson3_defconfig | 1 - arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - mm/Kconfig | 7 ------- mm/Makefile | 4 +++- mm/cma.h | 4 ++-- 6 files changed, 5 insertions(+), 13 deletions(-)arch/loongarch/configs/loongson3_defconfig +0
-0[...]
Quoted 12 lines
mm/cma.h +1
-1@@ -49,7 +49,7 @@ struct cma {char name[CMA_MAX_NAME ];int nranges;struct cma_memrange ranges[CMA_MAX_RANGES ]; -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS /* the number of CMA page successful allocations */ atomic64_t nr_pages_succeeded;/* the number of CMA page allocation failures */ mm/cma.h static inline unsigned long cma_bitmap_m · line 86
Quoted 8 lines
mm/cma.h +1
-1@@ -80,7 +80,7 @@ static inline unsigned long cma_bitmap_mreturn cmr->count >> cma->order_per_bit; } -#ifdef CONFIG_CMA_SYSFS +#ifdef CONFIG_SYSFS void cma_sysfs_account_success_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_fail_pages (struct cma *cma,unsigned long nr_pages);void cma_sysfs_account_release_pages (struct cma *cma,unsigned long nr_pages);Why don't you check
CONFIG_CMAtogether? I think that makes the change more complete and safe.Quoted 2 lines
I found there is no file that can be compiled without
CONFIG_CMAbut still including this header file, so I expect no real issue for now, though.
Quoted 6 lines
This would actually make no difference. This header file is internal and not expected to be included by any file besides that CMA core itself, so it is assumed that
CONFIG_CMA=ywhenever this header file is used. If not, then things would break already, even without my proposed changes (due tocma_areasandcma_area_countbeing declared but never defined).
Makes sense.
Thanks,
SJ
[...]
Quoted 5 lines · Jean Delvare
The sysfs interface to CMA has a marginal runtime cost and a small footprint, there's no reason not to include it in all kernels where the dependencies are satisfied.
Signed-off-by Jean Delvare <[email protected]>
Signature · 2 lines
Oscar Salvador SUSE Labs