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, 10 Apr 2018 07:39:36 +0900
From:   Minchan Kim <minchan.kim@...il.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     Minchan Kim <minchan@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: Re: [PATCH v3 4/4] zram: introduce zram memory tracking

On Mon, 9 Apr 2018 10:03:45 +0200
Greg KH <gregkh@...uxfoundation.org> wrote:

> On Mon, Apr 09, 2018 at 02:54:35PM +0900, Minchan Kim wrote:
> > zRam as swap is useful for small memory device. However, swap means
> > those pages on zram are mostly cold pages due to VM's LRU algorithm.
> > Especially, once init data for application are touched for launching,
> > they tend to be not accessed any more and finally swapped out.
> > zRAM can store such cold pages as compressed form but it's pointless
> > to keep in memory. Better idea is app developers free them directly
> > rather than remaining them on heap.
> > 
> > This patch tell us last access time of each block of zram via
> > "cat /sys/kernel/debug/zram/zram0/block_state".
> > 
> > The output is as follows,
> >       300    75.033841 .wh
> >       301    63.806904 s..
> >       302    63.806919 ..h
> > 
> > First column is zram's block index and 3rh one represents symbol
> > (s: same page w: written page to backing store h: huge page) of the
> > block state. Second column represents usec time unit of the block
> > was last accessed. So above example means the 300th block is accessed
> > at 75.033851 second and it was huge so it was written to the backing
> > store.
> > 
> > Admin can leverage this information to catch cold|incompressible pages
> > of process with *pagemap* once part of heaps are swapped out.
> > 
> > Cc: Greg KH <gregkh@...uxfoundation.org>
> > Signed-off-by: Minchan Kim <minchan@...nel.org>
> > ---
> >  Documentation/blockdev/zram.txt |  24 ++++++
> >  drivers/block/zram/Kconfig      |   9 +++
> >  drivers/block/zram/zram_drv.c   | 139 +++++++++++++++++++++++++++++---
> >  drivers/block/zram/zram_drv.h   |   5 ++
> >  4 files changed, 166 insertions(+), 11 deletions(-)
> > 
> > diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
> > index 78db38d02bc9..45509c7d5716 100644
> > --- a/Documentation/blockdev/zram.txt
> > +++ b/Documentation/blockdev/zram.txt
> > @@ -243,5 +243,29 @@ to backing storage rather than keeping it in memory.
> >  User should set up backing device via /sys/block/zramX/backing_dev
> >  before disksize setting.
> >  
> > += memory tracking
> > +
> > +With CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the
> > +zram block. It could be useful to catch cold or incompressible
> > +pages of the proess with*pagemap.
> > +If you enable the feature, you could see block state via
> > +/sys/kernel/debug/zram/zram0/block_state". The output is as follows,
> > +
> > +	  300    75.033841 .wh
> > +	  301    63.806904 s..
> > +	  302    63.806919 ..h
> > +
> > +First column is zram's block index.
> > +Second column is access time.
> > +Third column is state of the block.
> > +(s: same page
> > +w: written page to backing store
> > +h: huge page)
> > +
> > +First line of above example says 300th block is accessed at 75.033841sec
> > +and the block's state is huge so it is written back to the backing
> > +storage. It's a debugging feature so anyone shouldn't rely on it to work
> > +properly.
> > +
> >  Nitin Gupta
> >  ngupta@...are.org
> > diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
> > index ac3a31d433b2..efe60c82d8ec 100644
> > --- a/drivers/block/zram/Kconfig
> > +++ b/drivers/block/zram/Kconfig
> > @@ -26,3 +26,12 @@ config ZRAM_WRITEBACK
> >  	 /sys/block/zramX/backing_dev.
> >  
> >  	 See zram.txt for more infomration.
> > +
> > +config ZRAM_MEMORY_TRACKING
> > +	bool "Tracking zram block status"
> > +	depends on ZRAM
> > +	select DEBUG_FS
> 
> Select?  Shouldn't you depend on this instead?  Selecting is a pain to
> try to track down what is keeping an option enabled.

Okay, I will modify.

> 
> > +	help
> > +	  With this feature, admin can track the state of allocated block
> > +	  of zRAM. Admin could see the information via
> > +	  /sys/kernel/debug/zram/zramX/block_state.
> 
> A short note here as to where to find the documentation for what that
> info is (i.e. in the file you wrote above?)

Yub. Will change.

> 
> > +#else
> > +static void zram_debugfs_create(void) {};
> > +static void zram_debugfs_destroy(void) {};
> > +static void zram_accessed(struct zram *zram, u32 index) {};
> > +static void zram_reset_access(struct zram *zram, u32 index) {};
> > +static void zram_debugfs_register(struct zram *zram) {};
> > +static void zram_debugfs_unregister(struct zram *zram) {};
> > +#endif
> 
> Much nicer, thanks!
> 
> The above was only very minor nits, no need to change anything if you
> don't want to.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>

I will wait a few days for getting review from Sergey and resend it with
fix.
Thanks for the review, Greg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ