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:   Tue, 13 Sep 2022 11:10:00 +0900
From:   Sergey Senozhatsky <senozhatsky@...omium.org>
To:     Brian Geffon <bgeffon@...gle.com>
Cc:     Sergey Senozhatsky <senozhatsky@...omium.org>,
        Minchan Kim <minchan@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Nitin Gupta <ngupta@...are.org>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-mm <linux-mm@...ck.org>
Subject: Re: [PATCHv2] zram: do not waste zram_table_entry flags bits

On (22/09/12 22:07), Brian Geffon wrote:
> > On (22/09/12 11:39), Brian Geffon wrote:
> > > > zram_table_entry::flags stores object size in the lower bits and
> > > > zram pageflags in the upper bits. However, for some reason, we
> > > > use 24 lower bits, while maximum zram object size is PAGE_SIZE,
> > > > which requires PAGE_SHIFT bits (up to 16 on arm64). This wastes
> > > > 24 - PAGE_SHIFT bits that we can use for additional zram pageflags
> > > > instead.
> > > >
> > > > Also add a BUILD_BUG_ON() to alert us should we run out of bits
> > > > in zram_table_entry::flags.
> > > >
> > > > Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
> > > > ---
> > > >  drivers/block/zram/zram_drv.c |  2 ++
> > > >  drivers/block/zram/zram_drv.h | 15 +++++++--------
> > > >  2 files changed, 9 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> > > > index f3948abce2f7..07913bcdb5c2 100644
> > > > --- a/drivers/block/zram/zram_drv.c
> > > > +++ b/drivers/block/zram/zram_drv.c
> > > > @@ -2449,6 +2449,8 @@ static int __init zram_init(void)
> > > >  {
> > > >         int ret;
> > > >
> > > > +       BUILD_BUG_ON(__NR_ZRAM_PAGEFLAGS > BITS_PER_LONG);
> > >
> > > Should this be >= BITS_PER_LONG?
> >
> > __NR_ZRAM_PAGEFLAGS == BITS_PER_LONG == 64 (e.g. on 64 bit host)
> > means that the last valid zram pageflag (and __NR_ZRAM_PAGEFLAGS
> > is not a valid pageflag) is __NR_ZRAM_PAGEFLAGS - 1, which is 63
> > and which is a valid BIT() offset for u64.
> >
> > So __NR_ZRAM_PAGEFLAGS == BITS_PER_LONG should be a valid case.
> 
> I apologize, you are correct.

No worries! It's always good to double check.

> Reviewed-by: Brian Geffon <bgeffon@...gle.com>

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ