From: Xueyuan Chen <xueyuan.chen21@gmail.com>
To: Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Xueyuan Chen <xueyuan.chen21@gmail.com>
Subject: [PATCH] mm/zsmalloc: keep fullness stats consistent with CONFIG_ZSMALLOC_STAT
Date: Fri, 06 Nov 2026 17:42:43 +0800 [thread overview]
Message-ID: <20261106-zsmalloc_stat-v1-1-b574f4714adf@gmail.com> (raw)
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
next reply other threads:[~2026-11-06 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 9:42 Xueyuan Chen [this message]
2026-11-06 16:34 ` Nhat Pham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106-zsmalloc_stat-v1-1-b574f4714adf@gmail.com \
--to=xueyuan.chen21@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®