linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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: [PATCH] zram: do not waste zram_table_entry flags bits
Date: Mon, 12 Sep 2022 10:57:38 -0400	[thread overview]
Message-ID: <CADyq12yK98A3Gn8qA+PiYFsT+Oj7nJKROSenW-kse_LLf4ziyQ@mail.gmail.com> (raw)
In-Reply-To: <Yx9HfpsJ3JJZLJJ9@google.com>

On Mon, Sep 12, 2022 at 10:51 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> On (22/09/12 23:37), Sergey Senozhatsky wrote:
> > > > -#define ZRAM_FLAG_SHIFT 24
> > > > +#define ZRAM_FLAG_SHIFT (PAGE_SHIFT + 1)
> > >
> > > Why not just hard code 16 with an explanation that it cannot be
> > > increased further using the analysis you did in the other thread? It's
> > > going to be tricky to reason about how many free flag bits actually
> > > remain with PAGE_SHIFT across all architectures, especially given we
> > > have no architecture specific flags.
> >
> > Well, zram should not make any assumptions on arch code. How do
> > we know that PAGE_SHIFT 16 is the max value we will ever have?
> > Some arch can come around someday and use PAGE_SHIFT say, 18,
> > and we won't be aware of it (using hardcoded value of 16) until
> > someone hits a really hard to debug problem in zram.
>
> And I'd probably also add something like this, to keep us alert should
> we run out of bits in the future:
>
> ---
>
> 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);
> +

Thanks Sergey, yes, with the BUILD_BUG_ON I think using PAGE_SHIFT is
fine, my concern was primarily that a flag could overwrite a bit of
the size field, a BUILD_BUG_ON addresses that.

>         ret = cpuhp_setup_state_multi(CPUHP_ZCOMP_PREPARE, "block/zram:prepare",
>                                       zcomp_cpu_up_prepare, zcomp_cpu_dead);
>         if (ret < 0)

Thanks,
Brian


      reply	other threads:[~2022-09-12 14:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  5:37 Sergey Senozhatsky
2022-09-12 14:20 ` Brian Geffon
2022-09-12 14:37   ` Sergey Senozhatsky
2022-09-12 14:51     ` Sergey Senozhatsky
2022-09-12 14:57       ` Brian Geffon [this message]

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=CADyq12yK98A3Gn8qA+PiYFsT+Oj7nJKROSenW-kse_LLf4ziyQ@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