Re: [PATCHv2 0/4] zsmalloc: make zspage chain size configurable

From: Sergey Senozhatsky
Date: Sun Jan 15 2023 - 01:20:21 EST


On (23/01/15 13:21), Sergey Senozhatsky wrote:
> On (23/01/14 13:34), Mike Kravetz wrote:
> > I did the following:
> >
> > - Start with clean v6.2-rc3
> > Perform echo, did not see issue
> >
> > - Applied your 5 patches (includes the zsmalloc: turn chain size config option
> > into UL constant patch). Took default value for ZSMALLOC_CHAIN_SIZE of 8.
> > Performed echo, recreated issue.
> >
> > - Changed ZSMALLOC_CHAIN_SIZE to 1.
> > Perform echo, did not see issue
>
> The patch set basically just adjusts $NUM in calculate_zspage_chain_size():
>
> for (i = 1; i <= $NUM; i++)
>
> It changes default 4 to 8. Can't really see how this can cause problems.

OK, I guess it overflows zspage isolated counter, which is a 3 bit
integer, so the max chain-size we can have is b111 == 7.

We probably need something like below (this should not increase sizeof
zspage):

---

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 290053e648b0..86b742a613ee 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -129,7 +129,7 @@
#define HUGE_BITS 1
#define FULLNESS_BITS 2
#define CLASS_BITS 8
-#define ISOLATED_BITS 3
+#define ISOLATED_BITS 5
#define MAGIC_VAL_BITS 8

#define MAX(a, b) ((a) >= (b) ? (a) : (b))