[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yx9HfpsJ3JJZLJJ9@google.com>
Date: Mon, 12 Sep 2022 23:51:42 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Brian Geffon <bgeffon@...gle.com>, Minchan Kim <minchan@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Nitin Gupta <ngupta@...are.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-mm <linux-mm@...ck.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>
Subject: Re: [PATCH] zram: do not waste zram_table_entry flags bits
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);
+
ret = cpuhp_setup_state_multi(CPUHP_ZCOMP_PREPARE, "block/zram:prepare",
zcomp_cpu_up_prepare, zcomp_cpu_dead);
if (ret < 0)
Powered by blists - more mailing lists