* [PATCH 0/1] erofs: fix unused pcluster_pools for higher page sizes
@ 2026-08-16 13:07 Ojaswin Mujoo
2026-08-16 13:07 ` [PATCH 1/1] " Ojaswin Mujoo
0 siblings, 1 reply; 2+ messages in thread
From: Ojaswin Mujoo @ 2026-08-16 13:07 UTC (permalink / raw)
To: linux-erofs
Cc: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale, Hongbo Li,
Chunhai Guo, linux-kernel
When inserting the erofs module on an older kernel with a 64K page size
machine, we were running into the following dmesg followed by a stack
dump (Needs, CONFIG_DEBUG_VM=y):
[ 4.616501] kmem_cache of name 'erofs_pcluster-16' already exists
The root cause is that on 64k page size:
Z_EROFS_PCLUSTER_MAX_PAGES = 1M / 16k = 16
and, on that kernel, our logic to create the pcluster pool is as:
static struct z_erofs_pcluster_slab pcluster_pool[] __read_mostly = {
_PCLP(1), _PCLP(4), _PCLP(16), _PCLP(64), _PCLP(128),
_PCLP(Z_EROFS_PCLUSTER_MAX_PAGES)
};
so we were ending up creating kmemcaches for nr_pages= 1, 4, 16, 64,
128, and Z_EROFS_PCLUSTER_MAX_PAGES (=16, again). This caused the
kmem_cache sanity check to emit the warning.
When comparing with the upstream code, I noticed that this issue has
been fixed as a side effect of the patch:
commit 7361d1e3763baaf7b9349c576137851458ad38d1
Author: Gao Xiang <xiang@kernel.org>
Date: Mon Mar 10 17:54:59 2025 +0800
erofs: support unaligned encoded data
which changes
static struct z_erofs_pcluster_slab pcluster_pool[] __read_mostly = {
_PCLP(1), _PCLP(4), _PCLP(16), _PCLP(64), _PCLP(128),
- _PCLP(Z_EROFS_PCLUSTER_MAX_PAGES)
+ _PCLP(Z_EROFS_PCLUSTER_MAX_PAGES + 1)
};
and hence the final cache has nr_pages = 17 and doesn't clash with the
nr_pages=16 cache anymore. However, this is still incorrect as on higher
page sizes like 64k we will never use nr_pages > 16 and the rest of the
caches are wasted.
So this patch intends to fix the issue on upstream first and if the
approach looks okay, I'll send a backport for other the older affected
kernels.
Regards,
ojaswin
Ojaswin Mujoo (1):
erofs: fix unused pcluster_pools for higher page sizes
fs/erofs/zdata.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] erofs: fix unused pcluster_pools for higher page sizes
2026-08-16 13:07 [PATCH 0/1] erofs: fix unused pcluster_pools for higher page sizes Ojaswin Mujoo
@ 2026-08-16 13:07 ` Ojaswin Mujoo
0 siblings, 0 replies; 2+ messages in thread
From: Ojaswin Mujoo @ 2026-08-16 13:07 UTC (permalink / raw)
To: linux-erofs
Cc: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale, Hongbo Li,
Chunhai Guo, linux-kernel, Shirisha G
pcluster_pool[] hardcodes {1,4,16,64,128,Z_EROFS_PCLUSTER_MAX_PAGES+1},
but the assumption of Z_EROFS_PCLUSTER_MAX_PAGES == 256 is only right
for 4k page sizes. For higher page sizes like 16k or 64k, This results
in us ending up with clusters bigger than what we will ever use, since
we only support upto 1MB of compressed data. For example, on 64k page
size we will only ever use clusters with nrpages= 1, 4 and 17.
This patch fixes the allocation for such higher pages sizes by adding
some compile time checks.
Below are the clusters created right after boot on a 64KB page size
machine
$cat /proc/slabinfo | grep pcluster | cut -d" " -f1:
Before the patch:
erofs_pcluster-1
erofs_pcluster-4
erofs_pcluster-16
erofs_pcluster-17
erofs_pcluster-64
erofs_pcluster-128
After the patch:
erofs_pcluster-1
erofs_pcluster-4
erofs_pcluster-17
Fixes: 9f6cc76e6ff0 ("erofs: introduce physical cluster slab pools")
Reported-by: Shirisha G <shirisha@linux.ibm.com>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
fs/erofs/zdata.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 602ba8b7cc79..5c2c22ed64d0 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -128,7 +128,17 @@ struct z_erofs_pcluster_slab {
#define _PCLP(n) { .maxpages = n }
static struct z_erofs_pcluster_slab pcluster_pool[] __read_mostly = {
- _PCLP(1), _PCLP(4), _PCLP(16), _PCLP(64), _PCLP(128),
+ _PCLP(1),
+ _PCLP(4),
+#if Z_EROFS_PCLUSTER_MAX_PAGES > 16
+ _PCLP(16),
+#endif
+#if Z_EROFS_PCLUSTER_MAX_PAGES > 64
+ _PCLP(64),
+#endif
+#if Z_EROFS_PCLUSTER_MAX_PAGES > 128
+ _PCLP(128),
+#endif
_PCLP(Z_EROFS_PCLUSTER_MAX_PAGES + 1)
};
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-16 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16 13:07 [PATCH 0/1] erofs: fix unused pcluster_pools for higher page sizes Ojaswin Mujoo
2026-08-16 13:07 ` [PATCH 1/1] " Ojaswin Mujoo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox