Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

zram: introduce per-device debug_stat sysfs node

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 avoid any confusion, we will 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. This stat is temporary any will be useful in case if any
per-cpu compression streams regressions will be reported.

Link: http://lkml.kernel.org/r/20160513230834.GB26763@bbox
Link: http://lkml.kernel.org/r/20160511134553.12655-1-sergey.senozhatsky@gmail.com
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Linus Torvalds
623e47fc 43209ea2

+32
+9
Documentation/ABI/testing/sysfs-block-zram
··· 166 166 The mm_stat file is read-only and represents device's mm 167 167 statistics (orig_data_size, compr_data_size, etc.) in a format 168 168 similar to block layer statistics file format. 169 + 170 + What: /sys/block/zram<id>/debug_stat 171 + Date: July 2016 172 + Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> 173 + Description: 174 + The debug_stat file is read-only and represents various 175 + device's debugging info useful for kernel developers. Its 176 + format is not documented intentionally and may change 177 + anytime without any notice.
+1
Documentation/blockdev/zram.txt
··· 172 172 pages_compacted RO the number of pages freed during compaction 173 173 (available only via zram<id>/mm_stat node) 174 174 compact WO trigger memory compaction 175 + debug_stat RO this file is used for zram debugging purposes 175 176 176 177 WARNING 177 178 =======
+21
drivers/block/zram/zram_drv.c
··· 435 435 return ret; 436 436 } 437 437 438 + static ssize_t debug_stat_show(struct device *dev, 439 + struct device_attribute *attr, char *buf) 440 + { 441 + int version = 1; 442 + struct zram *zram = dev_to_zram(dev); 443 + ssize_t ret; 444 + 445 + down_read(&zram->init_lock); 446 + ret = scnprintf(buf, PAGE_SIZE, 447 + "version: %d\n%8llu\n", 448 + version, 449 + (u64)atomic64_read(&zram->stats.writestall)); 450 + up_read(&zram->init_lock); 451 + 452 + return ret; 453 + } 454 + 438 455 static DEVICE_ATTR_RO(io_stat); 439 456 static DEVICE_ATTR_RO(mm_stat); 457 + static DEVICE_ATTR_RO(debug_stat); 440 458 ZRAM_ATTR_RO(num_reads); 441 459 ZRAM_ATTR_RO(num_writes); 442 460 ZRAM_ATTR_RO(failed_reads); ··· 736 718 if (!handle) { 737 719 zcomp_strm_release(zram->comp, zstrm); 738 720 zstrm = NULL; 721 + 722 + atomic64_inc(&zram->stats.writestall); 739 723 740 724 handle = zs_malloc(meta->mem_pool, clen, 741 725 GFP_NOIO | __GFP_HIGHMEM); ··· 1201 1181 &dev_attr_comp_algorithm.attr, 1202 1182 &dev_attr_io_stat.attr, 1203 1183 &dev_attr_mm_stat.attr, 1184 + &dev_attr_debug_stat.attr, 1204 1185 NULL, 1205 1186 }; 1206 1187
+1
drivers/block/zram/zram_drv.h
··· 85 85 atomic64_t zero_pages; /* no. of zero filled pages */ 86 86 atomic64_t pages_stored; /* no. of pages currently stored */ 87 87 atomic_long_t max_used_pages; /* no. of maximum pages stored */ 88 + atomic64_t writestall; /* no. of write slow paths */ 88 89 }; 89 90 90 91 struct zram_meta {