Received: by 10.213.65.68 with SMTP id h4csp2317228imn; Mon, 9 Apr 2018 01:08:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/+EJC0xspHb2e0hS0GTsOryjSydgVZrWmVLCdduJ64G5P1LgBPk8nYQUor//W5b3yYjSrp X-Received: by 10.99.106.137 with SMTP id f131mr17292169pgc.123.1523261299675; Mon, 09 Apr 2018 01:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523261299; cv=none; d=google.com; s=arc-20160816; b=UcoSg6uGYrlMo+wK1SBfueA0cdb3SwAkKpxKSV2rJEgsSeN18IOqJG4vrlYD/wB8p3 L6yeJElpmlgDvG71J32MZ05hJmAg4OgROVm0yzouwX+K4KyrdL6BoV+5qriYKfhrIL4U K/Bez8A4g6hZtnxGs2cJ3xntdMRDXaNOB1Hx1hi8abIr+4N5k5yACPVTHHMuGdRrLyCo /svo32pFaG2nimtFjQNBP/079/crcKwLqZG2W7OzK3L+4AHS/s3kIcSquWksoyjAmRL+ PuwrRavXaKlijs6YqdX+sL4p1gexbM3W8zTzs+eEd0flZ3dUjW6DFUKxCzGSOGVReB4d 1i0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=QrR46qX5ATzyxyADOOJMsxb2LFRl/ES/rwo1AFGve+E=; b=ieyEmHrTtiE+UzdIXLgiQUpvVEDCl0Mf/BN0aKKR0ZmozHRb5/KuNmtjFLnSVmvKzS 7zlbLkMtpf44AmpRX6SxkUbU0UfNleFwdt8Uh53rPhvZ6TQ2FZG1dkcC348vGqJ/Cp9W T20XhZDnRpLv4CwWQKr320GdylKhiljMT7udJlZPUcY2PNFPsSgxmzujXckCJ5h472Zf uyNyDu87jI9MoAp5R3EjePUFy3CenB9d/MBXrL2dqK8bjqSq7LXUsU4Eyx247beSkOVu J4fJt/wzoXtzRKbuhWyyecjYEmfCPy6eIZ5QiI3k+kkdPVM1nh7UATyvGlwfQlGJm/Vh JUSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o30si11091500pgc.282.2018.04.09.01.07.40; Mon, 09 Apr 2018 01:08:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbeDIID4 (ORCPT + 99 others); Mon, 9 Apr 2018 04:03:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50156 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581AbeDIIDz (ORCPT ); Mon, 9 Apr 2018 04:03:55 -0400 Received: from localhost (unknown [37.169.215.210]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C49DCD31; Mon, 9 Apr 2018 08:03:53 +0000 (UTC) Date: Mon, 9 Apr 2018 10:03:45 +0200 From: Greg KH To: Minchan Kim Cc: Andrew Morton , LKML , Sergey Senozhatsky Subject: Re: [PATCH v3 4/4] zram: introduce zram memory tracking Message-ID: <20180409080345.GC18095@kroah.com> References: <20180409055435.135695-1-minchan@kernel.org> <20180409055435.135695-5-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409055435.135695-5-minchan@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Minchan Kim > --- > 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@vflare.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. > + 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?) > +#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