[PATCH v2 1/3] mm/zsmalloc: remove CONFIG_ZSMALLOC_STAT

From: Xueyuan Chen

Date: Mon Nov 09 2026 - 08:05:57 EST


CONFIG_ZSMALLOC_STAT only controls the debugfs interface. The class
counters are updated regardless of this option.

Remove the CONFIG_ZSMALLOC_STAT guards and rely on the debugfs API
stubs when CONFIG_DEBUG_FS=n. Skip statistics setup silently when
debugfs is unavailable.

Suggested-by: Nhat Pham <nphamcs@xxxxxxxxx>
Signed-off-by: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
---
mm/zsmalloc.c | 33 ++-------------------------------
1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7ef80e0da626..104ccf3aa170 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -222,9 +222,7 @@ struct zs_size_stat {
unsigned long objs[NR_CLASS_STAT_TYPES];
};

-#ifdef CONFIG_ZSMALLOC_STAT
static struct dentry *zs_stat_root;
-#endif

static size_t huge_class_size;

@@ -279,9 +277,7 @@ struct zs_pool {
/* Compact classes */
struct shrinker *shrinker;

-#ifdef CONFIG_ZSMALLOC_STAT
struct dentry *stat_dentry;
-#endif
#ifdef CONFIG_COMPACTION
struct work_struct free_work;
#endif
@@ -565,14 +561,10 @@ static inline unsigned long class_stat_read(struct size_class *class, int type)
return class->stats.objs[type];
}

-#ifdef CONFIG_ZSMALLOC_STAT
-
static void __init zs_stat_init(void)
{
- if (!debugfs_initialized()) {
- pr_warn("debugfs not available, stat dir not created\n");
+ if (!debugfs_initialized())
return;
- }

zs_stat_root = debugfs_create_dir("zsmalloc", NULL);
}
@@ -650,10 +642,8 @@ DEFINE_SHOW_ATTRIBUTE(zs_stats_size);

static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
{
- if (!zs_stat_root) {
- pr_warn("no root stat dir, not creating <%s> stat dir\n", name);
+ if (IS_ERR_OR_NULL(zs_stat_root))
return;
- }

pool->stat_dentry = debugfs_create_dir(name, zs_stat_root);

@@ -666,25 +656,6 @@ static void zs_pool_stat_destroy(struct zs_pool *pool)
debugfs_remove_recursive(pool->stat_dentry);
}

-#else /* CONFIG_ZSMALLOC_STAT */
-static void __init zs_stat_init(void)
-{
-}
-
-static void __exit zs_stat_exit(void)
-{
-}
-
-static inline void zs_pool_stat_create(struct zs_pool *pool, const char *name)
-{
-}
-
-static inline void zs_pool_stat_destroy(struct zs_pool *pool)
-{
-}
-#endif
-
-
/*
* For each size class, zspages are divided into different groups
* depending on their usage ratio. This function returns fullness

--
2.47.3