mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/zsmalloc: keep fullness stats consistent with CONFIG_ZSMALLOC_STAT
@ 2026-11-06  9:42 Xueyuan Chen
  2026-11-06 16:34 ` Nhat Pham
  0 siblings, 1 reply; 2+ messages in thread
From: Xueyuan Chen @ 2026-11-06  9:42 UTC (permalink / raw)
  To: Minchan Kim, Sergey Senozhatsky
  Cc: Andrew Morton, linux-mm, linux-kernel, Xueyuan Chen

The fullness-group counters are only used by the debugfs classes report,
which is enabled by CONFIG_ZSMALLOC_STAT. However, these counters are
stored and updated even when the option is disabled.

Make the counter storage and updates conditional on CONFIG_ZSMALLOC_STAT.
Keep ZS_OBJS_ALLOCATED and ZS_OBJS_INUSE, since zs_can_compact()
still needs these counters.

The behavior with CONFIG_ZSMALLOC_STAT=y remains unchanged.

Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>
---
 mm/zsmalloc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7ef80e0da626..eb77d7cd948c 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -212,8 +212,12 @@ enum fullness_group {
 };
 
 enum class_stat_type {
+#ifdef CONFIG_ZSMALLOC_STAT
 	/* NOTE: stats for 12 fullness groups here: from inuse 0 to 100 */
 	ZS_OBJS_ALLOCATED       = NR_FULLNESS_GROUPS,
+#else
+	ZS_OBJS_ALLOCATED,
+#endif
 	ZS_OBJS_INUSE,
 	NR_CLASS_STAT_TYPES,
 };
@@ -721,7 +725,9 @@ static void insert_zspage(struct size_class *class,
 				struct zspage *zspage,
 				int fullness)
 {
+#ifdef CONFIG_ZSMALLOC_STAT
 	class_stat_add(class, fullness, 1);
+#endif
 	list_add(&zspage->list, &class->fullness_list[fullness]);
 	zspage->fullness = fullness;
 }
@@ -737,7 +743,9 @@ static void remove_zspage(struct size_class *class, struct zspage *zspage)
 	VM_BUG_ON(list_empty(&class->fullness_list[fullness]));
 
 	list_del_init(&zspage->list);
+#ifdef CONFIG_ZSMALLOC_STAT
 	class_stat_sub(class, fullness, 1);
+#endif
 }
 
 /*
@@ -1896,7 +1904,9 @@ static void async_free_zspage(struct work_struct *work)
 
 		class = zspage_class(pool, zspage);
 		spin_lock(&class->lock);
+#ifdef CONFIG_ZSMALLOC_STAT
 		class_stat_sub(class, ZS_INUSE_RATIO_0, 1);
+#endif
 		__free_zspage(pool, class, zspage);
 		spin_unlock(&class->lock);
 	}

---
base-commit: 21a7f44fd0765fcc5194130b28767786eba1d1e7

--  
Best regards,
Xueyuan


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06  9:42 [PATCH] mm/zsmalloc: keep fullness stats consistent with CONFIG_ZSMALLOC_STAT Xueyuan Chen
2026-11-06 16:34 ` Nhat Pham

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®