]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
zram: add stat to gather incompressible pages since zram set up
authorMinchan Kim <minchan@kernel.org>
Tue, 15 Dec 2020 03:14:32 +0000 (19:14 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Dec 2020 20:13:47 +0000 (12:13 -0800)
Currently, zram supports the stat via /sys/block/zram/mm_stat to represent
how many of incompressible pages are stored at the moment but it couldn't
show how many times incompressible pages were wrote down since zram set
up.  It's also good indication to see how zram is effective in the system.

Link: https://lkml.kernel.org/r/20201130201907.1284910-1-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/admin-guide/blockdev/zram.rst
drivers/block/zram/zram_drv.c
drivers/block/zram/zram_drv.h

index 8f3cfa42e443a77a6c02fb05972c15f26528a9d4..03f1105b21b7038ac3f189cab2d6e98238927bb5 100644 (file)
@@ -266,6 +266,7 @@ line of text and contains the following stats separated by whitespace:
                   No memory is allocated for such pages.
  pages_compacted  the number of pages freed during compaction
  huge_pages      the number of incompressible pages
+ huge_pages_since the number of incompressible pages since zram set up
  ================ =============================================================
 
 File /sys/block/zram<id>/bd_stat
index 9a1e6ee4dbeff5fd84fea31ea3834c267c99fd11..9481fa9eedd028a3a882c93e549825517c54181a 100644 (file)
@@ -1084,7 +1084,7 @@ static ssize_t mm_stat_show(struct device *dev,
        max_used = atomic_long_read(&zram->stats.max_used_pages);
 
        ret = scnprintf(buf, PAGE_SIZE,
-                       "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu\n",
+                       "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu\n",
                        orig_size << PAGE_SHIFT,
                        (u64)atomic64_read(&zram->stats.compr_data_size),
                        mem_used << PAGE_SHIFT,
@@ -1092,7 +1092,8 @@ static ssize_t mm_stat_show(struct device *dev,
                        max_used << PAGE_SHIFT,
                        (u64)atomic64_read(&zram->stats.same_pages),
                        pool_stats.pages_compacted,
-                       (u64)atomic64_read(&zram->stats.huge_pages));
+                       (u64)atomic64_read(&zram->stats.huge_pages),
+                       (u64)atomic64_read(&zram->stats.huge_pages_since));
        up_read(&zram->init_lock);
 
        return ret;
@@ -1424,6 +1425,7 @@ out:
        if (comp_len == PAGE_SIZE) {
                zram_set_flag(zram, index, ZRAM_HUGE);
                atomic64_inc(&zram->stats.huge_pages);
+               atomic64_inc(&zram->stats.huge_pages_since);
        }
 
        if (flags) {
index f2fd46daa7604583b1c3bebaba86b484bca901c7..9cabcbb13fd9f8f1c338aecb15b210d784428bdc 100644 (file)
@@ -78,6 +78,7 @@ struct zram_stats {
        atomic64_t notify_free; /* no. of swap slot free notifications */
        atomic64_t same_pages;          /* no. of same element filled pages */
        atomic64_t huge_pages;          /* no. of huge pages */
+       atomic64_t huge_pages_since;    /* no. of huge pages since zram set up */
        atomic64_t pages_stored;        /* no. of pages currently stored */
        atomic_long_t max_used_pages;   /* no. of maximum pages stored */
        atomic64_t writestall;          /* no. of write slow paths */