diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2015-04-15 19:16:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:21 -0400 |
commit | 4f2109f60881585dc04fa0b5657a60556576625c (patch) | |
tree | 18965ef4da50218fefe6b899b5bdb35f4edb7d5c /drivers/block/zram | |
parent | 2f6a3bed7347ee94fe57b3501fddaa646a26d890 (diff) |
zram: export new 'mm_stat' sysfs attrs
Per-device `zram<id>/mm_stat' file provides mm statistics of a particular
zram device in a format similar to block layer statistics. The file
consists of a single line and represents the following stats (separated by
whitespace):
orig_data_size
compr_data_size
mem_used_total
mem_limit
mem_used_max
zero_pages
num_migrated
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram')
-rw-r--r-- | drivers/block/zram/zram_drv.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 1b63a717bdbb..c94a1a98e301 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -1051,7 +1051,37 @@ static ssize_t io_stat_show(struct device *dev, | |||
1051 | return ret; | 1051 | return ret; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | static ssize_t mm_stat_show(struct device *dev, | ||
1055 | struct device_attribute *attr, char *buf) | ||
1056 | { | ||
1057 | struct zram *zram = dev_to_zram(dev); | ||
1058 | u64 orig_size, mem_used = 0; | ||
1059 | long max_used; | ||
1060 | ssize_t ret; | ||
1061 | |||
1062 | down_read(&zram->init_lock); | ||
1063 | if (init_done(zram)) | ||
1064 | mem_used = zs_get_total_pages(zram->meta->mem_pool); | ||
1065 | |||
1066 | orig_size = atomic64_read(&zram->stats.pages_stored); | ||
1067 | max_used = atomic_long_read(&zram->stats.max_used_pages); | ||
1068 | |||
1069 | ret = scnprintf(buf, PAGE_SIZE, | ||
1070 | "%8llu %8llu %8llu %8lu %8ld %8llu %8llu\n", | ||
1071 | orig_size << PAGE_SHIFT, | ||
1072 | (u64)atomic64_read(&zram->stats.compr_data_size), | ||
1073 | mem_used << PAGE_SHIFT, | ||
1074 | zram->limit_pages << PAGE_SHIFT, | ||
1075 | max_used << PAGE_SHIFT, | ||
1076 | (u64)atomic64_read(&zram->stats.zero_pages), | ||
1077 | (u64)atomic64_read(&zram->stats.num_migrated)); | ||
1078 | up_read(&zram->init_lock); | ||
1079 | |||
1080 | return ret; | ||
1081 | } | ||
1082 | |||
1054 | static DEVICE_ATTR_RO(io_stat); | 1083 | static DEVICE_ATTR_RO(io_stat); |
1084 | static DEVICE_ATTR_RO(mm_stat); | ||
1055 | ZRAM_ATTR_RO(num_reads); | 1085 | ZRAM_ATTR_RO(num_reads); |
1056 | ZRAM_ATTR_RO(num_writes); | 1086 | ZRAM_ATTR_RO(num_writes); |
1057 | ZRAM_ATTR_RO(failed_reads); | 1087 | ZRAM_ATTR_RO(failed_reads); |
@@ -1080,6 +1110,7 @@ static struct attribute *zram_disk_attrs[] = { | |||
1080 | &dev_attr_max_comp_streams.attr, | 1110 | &dev_attr_max_comp_streams.attr, |
1081 | &dev_attr_comp_algorithm.attr, | 1111 | &dev_attr_comp_algorithm.attr, |
1082 | &dev_attr_io_stat.attr, | 1112 | &dev_attr_io_stat.attr, |
1113 | &dev_attr_mm_stat.attr, | ||
1083 | NULL, | 1114 | NULL, |
1084 | }; | 1115 | }; |
1085 | 1116 | ||