From: Brian Geffon <bgeffon@google.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Nitin Gupta <ngupta@vflare.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCHv2] zram: do not waste zram_table_entry flags bits
Date: Mon, 12 Sep 2022 22:07:08 -0400 [thread overview]
Message-ID: <CADyq12xxxTWQ3Wz_jfayJA7k6u+20KAqhOSpqBxa3T0Zkr2pQg@mail.gmail.com> (raw)
In-Reply-To: <Yx/i2nQ/XVG334ag@google.com>
On Mon, Sep 12, 2022 at 9:54 PM Sergey Senozhatsky
<senozhatsky@chromium.org> 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@chromium.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.
Reviewed-by: Brian Geffon <bgeffon@google.com>
next prev parent reply other threads:[~2022-09-13 2:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 15:27 Sergey Senozhatsky
2022-09-12 15:39 ` Brian Geffon
2022-09-13 1:54 ` Sergey Senozhatsky
2022-09-13 2:07 ` Brian Geffon [this message]
2022-09-13 2:10 ` Sergey Senozhatsky
2022-09-15 16:36 ` Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADyq12xxxTWQ3Wz_jfayJA7k6u+20KAqhOSpqBxa3T0Zkr2pQg@mail.gmail.com \
--to=bgeffon@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox