linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH] zram: introduce per-device debug_stat sysfs node
Date: Fri, 13 May 2016 08:41:43 +0900	[thread overview]
Message-ID: <20160512234143.GA27204@bbox> (raw)
In-Reply-To: <20160511134553.12655-1-sergey.senozhatsky@gmail.com>

Hello Sergey,

On Wed, May 11, 2016 at 10:45:53PM +0900, Sergey Senozhatsky wrote:
> debug_stat sysfs is read-only and represents various debugging
> data that zram developers may need. This file is not meant to be
> used by anyone else: its content is not documented and will change
> any time w/o any notice. Therefore, the output of debug_stat file
> contains a version string. To reduce the possibility of contusion,

                                                          confusion

> etc. we would increase the version number every time we modify
> the output.
> 
> At the moment this file exports only one value -- the number of
> re-compressions, IOW, the number of times compression fast path
> has failed; which is a temporarily stats, that we will be using
> should any per-cpu regressions happen. It's excepted to go away.
 
                                              expected

> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> ---
>  Documentation/ABI/testing/sysfs-block-zram |  7 +++++++
>  Documentation/blockdev/zram.txt            |  1 +
>  drivers/block/zram/zram_drv.c              | 21 +++++++++++++++++++++
>  drivers/block/zram/zram_drv.h              |  1 +
>  4 files changed, 30 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-block-zram b/Documentation/ABI/testing/sysfs-block-zram
> index 2e69e83..740aada 100644
> --- a/Documentation/ABI/testing/sysfs-block-zram
> +++ b/Documentation/ABI/testing/sysfs-block-zram
> @@ -166,3 +166,10 @@ Description:
>  		The mm_stat file is read-only and represents device's mm
>  		statistics (orig_data_size, compr_data_size, etc.) in a format
>  		similar to block layer statistics file format.
> +
> +What:		/sys/block/zram<id>/debug_stat
> +Date:		July 2016
> +Contact:	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> +Description:
> +		The debug_stat file is read-only and represents various
> +		device's debugging info.
                                        for zram kernel developer so

                content is not documented for userspace intentionally
                and will change anytime without any notice.

would be more clear to waste user's time to read this. :)


> diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
> index d88f0c7..13100fb 100644
> --- a/Documentation/blockdev/zram.txt
> +++ b/Documentation/blockdev/zram.txt
> @@ -172,6 +172,7 @@ mem_limit         RW    the maximum amount of memory ZRAM can use to store
>  pages_compacted   RO    the number of pages freed during compaction
>                          (available only via zram<id>/mm_stat node)
>  compact           WO    trigger memory compaction
> +debug_stat        RO    this file is used for zram debugging purposes
>  
>  WARNING
>  =======
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 8fcfbeb..a629bd8d 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -435,8 +435,26 @@ static ssize_t mm_stat_show(struct device *dev,
>  	return ret;
>  }
>  
> +static ssize_t debug_stat_show(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	unsigned int version = 1;
> +	struct zram *zram = dev_to_zram(dev);
> +	ssize_t ret;
> +
> +	down_read(&zram->init_lock);
> +	ret = scnprintf(buf, PAGE_SIZE,
> +			"version: %d\n%8llu\n",
> +			version,
> +			(u64)atomic64_read(&zram->stats.num_recompress));
> +	up_read(&zram->init_lock);
> +
> +	return ret;
> +}
> +
>  static DEVICE_ATTR_RO(io_stat);
>  static DEVICE_ATTR_RO(mm_stat);
> +static DEVICE_ATTR_RO(debug_stat);
>  ZRAM_ATTR_RO(num_reads);
>  ZRAM_ATTR_RO(num_writes);
>  ZRAM_ATTR_RO(failed_reads);
> @@ -719,6 +737,8 @@ compress_again:
>  		zcomp_strm_release(zram->comp, zstrm);
>  		zstrm = NULL;
>  
> +		atomic64_inc(&zram->stats.num_recompress);
> +

It should be below "goto compress_again".

Other than that,

Acked-by: Minchan Kim <minchan@kernel.org>

Thanks!


>  		handle = zs_malloc(meta->mem_pool, clen,
>  				GFP_NOIO | __GFP_HIGHMEM);
>  		if (handle)
> @@ -1181,6 +1201,7 @@ static struct attribute *zram_disk_attrs[] = {
>  	&dev_attr_comp_algorithm.attr,
>  	&dev_attr_io_stat.attr,
>  	&dev_attr_mm_stat.attr,
> +	&dev_attr_debug_stat.attr,
>  	NULL,
>  };
>  
> diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
> index 06b1636..1fb45f7 100644
> --- a/drivers/block/zram/zram_drv.h
> +++ b/drivers/block/zram/zram_drv.h
> @@ -85,6 +85,7 @@ struct zram_stats {
>  	atomic64_t zero_pages;		/* no. of zero filled pages */
>  	atomic64_t pages_stored;	/* no. of pages currently stored */
>  	atomic_long_t max_used_pages;	/* no. of maximum pages stored */
> +	atomic64_t num_recompress;	/* no. of compression slow paths */
>  };
>  
>  struct zram_meta {
> -- 
> 2.8.2.372.g63a3502
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-05-12 23:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 13:45 [PATCH] zram: introduce per-device debug_stat sysfs node Sergey Senozhatsky
2016-05-12 23:41 ` Minchan Kim [this message]
2016-05-13  1:09   ` Sergey Senozhatsky
2016-05-13  6:23     ` Minchan Kim
2016-05-13  6:58       ` Sergey Senozhatsky
2016-05-13  7:05         ` Sergey Senozhatsky
2016-05-13  7:20           ` Minchan Kim
2016-05-13  7:41             ` Sergey Senozhatsky
2016-05-13  8:06             ` Sergey Senozhatsky
2016-05-13 23:05               ` Minchan Kim
2016-05-14  3:37                 ` Sergey Senozhatsky

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=20160512234143.GA27204@bbox \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.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).