linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Brian Geffon <bgeffon@google.com>, Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Nitin Gupta <ngupta@vflare.org>,
	linux-kernel@vger.kernel.org,
	Suleiman Souhlal <suleiman@google.com>,
	Rom Lemarchand <romlem@google.com>,
	linux-mm@kvack.org, Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [RESEND RFC] zram: Allow rw_page when page isn't written back.
Date: Mon, 12 Sep 2022 15:07:49 +0900	[thread overview]
Message-ID: <Yx7MtWdQ/WVE+EkG@google.com> (raw)
In-Reply-To: <Yx63e2lxNmEB3UhE@google.com>

On (22/09/12 13:37), Sergey Senozhatsky wrote:
> On (22/09/09 17:30), Sergey Senozhatsky wrote:
> > > +++ b/drivers/block/zram/zram_drv.h
> > > @@ -50,6 +50,7 @@ enum zram_pageflags {
> > >  	ZRAM_UNDER_WB,	/* page is under writeback */
> > >  	ZRAM_HUGE,	/* Incompressible page */
> > >  	ZRAM_IDLE,	/* not accessed page since last idle marking */
> > > +	ZRAM_NO_WB,	/* Do not allow page to be written back */
> > >  
> > >  	__NR_ZRAM_PAGEFLAGS,
> > >  };
> > 
> > Unrelated but somehow related.
> > 
> > I wonder if it's time for us to introduce a dedicated, say u16,
> > flags member to struct zram_table_entry. Unless my calculations
> > are extremely wrong, we are about to run out of spare bits in
> > zram_table_entry::flags on 32-bit systems.
> 
> Looking at it more - I wonder why do we define ZRAM_FLAG_SHIFT
> as 24? This is far more than maximum zram object size. Our max
> size needs PAGE_SHIFT bits (which is normally 12 bits, can be up
> to 16 (for 64k arm64 pages)). So we probably can start defining
> ZRAM_FLAG_SHIFT as (PAGE_SHIFT + 1).
> 
> Or am I missing something?

So I think what happened was that flags used to be a u8 member of
zram_table_entry, commit d2d5e762c8990 merged u16 size (which was
too large for object size) and u8 flags and just kept 8 bits for
flags (and somehow assumed 32-bit long? 32 - 8)

We definitely can store size in PAGE_SHIFT bits and have some
extra spare bits for zram pageflags. Would have been even nicer
if we could change type of flags from unsigned long to unsigned
int, but bit_lock requires "volatile unsigned long *" data type,
so because of bit_lock our zram_table_entriy is 4 extra bytes in
size. Which probably isn't too bad; having extra pageflag bits
on 32-bit systems is good news.

  reply	other threads:[~2022-09-12  6:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 12:50 [RESEND RFC] zram: Allow rw_page when page isn't written back Brian Geffon
2022-09-09  8:30 ` Sergey Senozhatsky
2022-09-12  4:37   ` Sergey Senozhatsky
2022-09-12  6:07     ` Sergey Senozhatsky [this message]
2022-09-23 19:31 ` Minchan Kim
2022-09-30 19:33   ` Brian Geffon
2022-09-30 19:52   ` [PATCH] zram: Always expose rw_page Brian Geffon
2022-10-03  2:59     ` Sergey Senozhatsky
2022-10-03 14:46       ` Brian Geffon
2022-10-03 14:48   ` [PATCH v2] " Brian Geffon

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=Yx7MtWdQ/WVE+EkG@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=bgeffon@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=romlem@google.com \
    --cc=suleiman@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).