Re: [PATCHv2 3/6] zsmalloc: fine-grained inuse ratio based fullness grouping

From: Sergey Senozhatsky
Date: Tue Feb 28 2023 - 23:05:32 EST


On (23/02/28 14:53), Minchan Kim wrote:
[..]
> > As of why I decided to go with defines, this is because zspage fullness
> > values and class stats are two conceptually different things, they don't
> > really fit in one single enum, unless enum's name is "zs_constants".
> > What do you think?
>
> Agree. We don't need to combine them, then.
> BTW, I still prefer the enum instead of 10 define.
>
> enum fullness_group {
> ZS_EMPTY,
> ZS_INUSE_RATIO_MIN,
> ZS_INUSE_RATIO_ALMOST_FULL = 7,
> ZS_INUSE_RATIO_MAX = 10,
> ZS_FULL,
> NR_ZS_FULLNESS,
> }

So we keep enum nesting? Sorry, I'm not exactly following.

We have fullness values (which we use independently) and stats array
which has overlapping offsets with fullness values.

[..]
> > I can change it to
> >
> > for (r = ZS_INUSE_RATIO_10; r <= ZS_INUSE_RATIO_70; r++)
> > and
> > for (r = ZS_INUSE_RATIO_80; r <= ZS_INUSE_RATIO_99; r++)
> >
> > which would be safer than using hard-coded numbers.
>
> I didn't mean to have hard code either but just wanted to show
> the intention to use the loop.

Got it. I just wanted to show that being very verbose (having every
constant documented) is nice :)

> >
> > Shall we actually instead report per inuse ratio stats instead? I sort
> > of don't see too many reasons to keep that below/above 3/4 thing.
>
> Oh, yeah. Since it's debugfs, we would get excuse to break.

This was in my original patch, but I decided to put a comment and keep
the old behavior. I probably will switch to a more precise reporting
(per inuse ratio) in a separate patch, so that we can easily revert it
without any impact on new fullness grouping.