summaryrefslogtreecommitdiffstats
path: root/drivers/block/zram
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2018-06-07 20:05:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-07 20:34:34 -0400
commit89e85bce4b02edb7408aebf69d5d1a6692a05f4f (patch)
treeedcf57724445af23cf3d97d904903722359f7d78 /drivers/block/zram
parentc4d6c4cc7bfd5ecc18548420b7fb9440cf8416ae (diff)
zram: mark incompressible page as ZRAM_HUGE
Mark incompressible pages so that we could investigate who is the owner of the incompressible pages once the page is swapped out via using upcoming zram memory tracker feature. With it, we could prevent such pages to be swapped out by using mlock. Otherwise we might remove them. This patch exposes new stat for huge pages via mm_stat. Link: http://lkml.kernel.org/r/20180416090946.63057-3-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>
Diffstat (limited to 'drivers/block/zram')
-rw-r--r--drivers/block/zram/zram_drv.c17
-rw-r--r--drivers/block/zram/zram_drv.h2
2 files changed, 16 insertions, 3 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 18dadeab775b..777fb3339f59 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -729,14 +729,15 @@ static ssize_t mm_stat_show(struct device *dev,
729 max_used = atomic_long_read(&zram->stats.max_used_pages); 729 max_used = atomic_long_read(&zram->stats.max_used_pages);
730 730
731 ret = scnprintf(buf, PAGE_SIZE, 731 ret = scnprintf(buf, PAGE_SIZE,
732 "%8llu %8llu %8llu %8lu %8ld %8llu %8lu\n", 732 "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu\n",
733 orig_size << PAGE_SHIFT, 733 orig_size << PAGE_SHIFT,
734 (u64)atomic64_read(&zram->stats.compr_data_size), 734 (u64)atomic64_read(&zram->stats.compr_data_size),
735 mem_used << PAGE_SHIFT, 735 mem_used << PAGE_SHIFT,
736 zram->limit_pages << PAGE_SHIFT, 736 zram->limit_pages << PAGE_SHIFT,
737 max_used << PAGE_SHIFT, 737 max_used << PAGE_SHIFT,
738 (u64)atomic64_read(&zram->stats.same_pages), 738 (u64)atomic64_read(&zram->stats.same_pages),
739 pool_stats.pages_compacted); 739 pool_stats.pages_compacted,
740 (u64)atomic64_read(&zram->stats.huge_pages));
740 up_read(&zram->init_lock); 741 up_read(&zram->init_lock);
741 742
742 return ret; 743 return ret;
@@ -805,6 +806,11 @@ static void zram_free_page(struct zram *zram, size_t index)
805{ 806{
806 unsigned long handle; 807 unsigned long handle;
807 808
809 if (zram_test_flag(zram, index, ZRAM_HUGE)) {
810 zram_clear_flag(zram, index, ZRAM_HUGE);
811 atomic64_dec(&zram->stats.huge_pages);
812 }
813
808 if (zram_wb_enabled(zram) && zram_test_flag(zram, index, ZRAM_WB)) { 814 if (zram_wb_enabled(zram) && zram_test_flag(zram, index, ZRAM_WB)) {
809 zram_wb_clear(zram, index); 815 zram_wb_clear(zram, index);
810 atomic64_dec(&zram->stats.pages_stored); 816 atomic64_dec(&zram->stats.pages_stored);
@@ -973,6 +979,7 @@ compress_again:
973 } 979 }
974 980
975 if (unlikely(comp_len >= huge_class_size)) { 981 if (unlikely(comp_len >= huge_class_size)) {
982 comp_len = PAGE_SIZE;
976 if (zram_wb_enabled(zram) && allow_wb) { 983 if (zram_wb_enabled(zram) && allow_wb) {
977 zcomp_stream_put(zram->comp); 984 zcomp_stream_put(zram->comp);
978 ret = write_to_bdev(zram, bvec, index, bio, &element); 985 ret = write_to_bdev(zram, bvec, index, bio, &element);
@@ -984,7 +991,6 @@ compress_again:
984 allow_wb = false; 991 allow_wb = false;
985 goto compress_again; 992 goto compress_again;
986 } 993 }
987 comp_len = PAGE_SIZE;
988 } 994 }
989 995
990 /* 996 /*
@@ -1046,6 +1052,11 @@ out:
1046 zram_slot_lock(zram, index); 1052 zram_slot_lock(zram, index);
1047 zram_free_page(zram, index); 1053 zram_free_page(zram, index);
1048 1054
1055 if (comp_len == PAGE_SIZE) {
1056 zram_set_flag(zram, index, ZRAM_HUGE);
1057 atomic64_inc(&zram->stats.huge_pages);
1058 }
1059
1049 if (flags) { 1060 if (flags) {
1050 zram_set_flag(zram, index, flags); 1061 zram_set_flag(zram, index, flags);
1051 zram_set_element(zram, index, element); 1062 zram_set_element(zram, index, element);
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 8d8959ceabd1..ff0547bdb586 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -47,6 +47,7 @@ enum zram_pageflags {
47 ZRAM_LOCK = ZRAM_FLAG_SHIFT, 47 ZRAM_LOCK = ZRAM_FLAG_SHIFT,
48 ZRAM_SAME, /* Page consists the same element */ 48 ZRAM_SAME, /* Page consists the same element */
49 ZRAM_WB, /* page is stored on backing_device */ 49 ZRAM_WB, /* page is stored on backing_device */
50 ZRAM_HUGE, /* Incompressible page */
50 51
51 __NR_ZRAM_PAGEFLAGS, 52 __NR_ZRAM_PAGEFLAGS,
52}; 53};
@@ -71,6 +72,7 @@ struct zram_stats {
71 atomic64_t invalid_io; /* non-page-aligned I/O requests */ 72 atomic64_t invalid_io; /* non-page-aligned I/O requests */
72 atomic64_t notify_free; /* no. of swap slot free notifications */ 73 atomic64_t notify_free; /* no. of swap slot free notifications */
73 atomic64_t same_pages; /* no. of same element filled pages */ 74 atomic64_t same_pages; /* no. of same element filled pages */
75 atomic64_t huge_pages; /* no. of huge pages */
74 atomic64_t pages_stored; /* no. of pages currently stored */ 76 atomic64_t pages_stored; /* no. of pages currently stored */
75 atomic_long_t max_used_pages; /* no. of maximum pages stored */ 77 atomic_long_t max_used_pages; /* no. of maximum pages stored */
76 atomic64_t writestall; /* no. of write slow paths */ 78 atomic64_t writestall; /* no. of write slow paths */