lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 23 Feb 2023 15:32:45 -0800
From:   Yosry Ahmed <yosryahmed@...gle.com>
To:     Minchan Kim <minchan@...nel.org>
Cc:     Sergey Senozhatsky <senozhatsky@...omium.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCHv2 2/6] zsmalloc: remove stat and fullness enums

On Thu, Feb 23, 2023 at 3:11 PM Minchan Kim <minchan@...nel.org> wrote:
>
> On Thu, Feb 23, 2023 at 12:04:47PM +0900, Sergey Senozhatsky wrote:
> > The fullness_group enum is nested (sub-enum) within the
> > class_stat_type enum. zsmalloc requires the values in both
> > enums to match, because zsmalloc passes these values to
> > generic functions, e.g. class_stat_inc() and class_stat_dec(),
> > after casting them to integers.
> >
> > Replace these enums (and enum nesting) and use simple defines
> > instead. Also rename some of zsmalloc stats defines, as they
> > sort of clash with zspage object tags.
> >
> > Suggested-by: Yosry Ahmed <yosryahmed@...gle.com>
> > Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
> > ---
> >  mm/zsmalloc.c | 104 ++++++++++++++++++++++----------------------------
> >  1 file changed, 45 insertions(+), 59 deletions(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index b57a89ed6f30..38ae8963c0eb 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -159,26 +159,18 @@
> >  #define ZS_SIZE_CLASSES      (DIV_ROUND_UP(ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE, \
> >                                     ZS_SIZE_CLASS_DELTA) + 1)
> >
> > -enum fullness_group {
> > -     ZS_EMPTY,
> > -     ZS_ALMOST_EMPTY,
> > -     ZS_ALMOST_FULL,
> > -     ZS_FULL,
> > -     NR_ZS_FULLNESS,
> > -};
> > +#define ZS_EMPTY             0
> > +#define ZS_ALMOST_EMPTY              1
> > +#define ZS_ALMOST_FULL               2
> > +#define ZS_FULL                      3
> > +#define ZS_OBJS_ALLOCATED    4
> > +#define ZS_OBJS_INUSE                5
> >
> > -enum class_stat_type {
> > -     CLASS_EMPTY,
> > -     CLASS_ALMOST_EMPTY,
> > -     CLASS_ALMOST_FULL,
> > -     CLASS_FULL,
> > -     OBJ_ALLOCATED,
> > -     OBJ_USED,
> > -     NR_ZS_STAT_TYPE,
> > -};
> > +#define NR_ZS_STAT           6
> > +#define NR_ZS_FULLNESS               4
>
> Using define list instead of enum list looks like going backward. :)
>
> Why can't we do this?
>
> enum class_stat_type {
>     ZS_EMPTY,
>     ZS_ALMOST_EMPTY,
>     ZS_ALMOST_FULL,
>     ZS_FULL,
>     NR_ZS_FULLNESS,
>     ZS_OBJ_ALLOCATED = NR_ZS_FULLNESS,
>     ZS_OBJ_USED,
>     NR_ZS_STAT,
> }

Right, I suggested getting rid of the extra enums, so merging them
into 1 is great.

>
>
> };
> >
> >  struct zs_size_stat {
> > -     unsigned long objs[NR_ZS_STAT_TYPE];
> > +     unsigned long objs[NR_ZS_STAT];
> >  };
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ