diff options
author | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> | 2018-04-05 19:24:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-06 00:36:26 -0400 |
commit | 60f5921a9a4f126e081318bd6bb2bc2798b7bba8 (patch) | |
tree | 46121f0c217ab40a3da0b439ca0899a9372fce73 /drivers/block/zram | |
parent | 010b495e2fa32353d0ef6aa70a8169e5ef617a15 (diff) |
zram: drop max_zpage_size and use zs_huge_class_size()
Remove ZRAM's enforced "huge object" value and use zsmalloc huge-class
watermark instead, which makes more sense.
TEST
- I used a 1G zram device, LZO compression back-end, original
data set size was 444MB. Looking at zsmalloc classes stats the
test ended up to be pretty fair.
BASE ZRAM/ZSMALLOC
=====================
zram mm_stat
498978816 191482495 199831552 0 199831552 15634 0
zsmalloc classes
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
...
151 2448 0 0 1240 1240 744 3 0
168 2720 0 0 4200 4200 2800 2 0
190 3072 0 0 10100 10100 7575 3 0
202 3264 0 0 380 380 304 4 0
254 4096 0 0 10620 10620 10620 1 0
Total 7 46 106982 106187 48787 0
PATCHED ZRAM/ZSMALLOC
=====================
zram mm_stat
498978816 182579184 194248704 0 194248704 15628 0
zsmalloc classes
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
...
151 2448 0 0 1240 1240 744 3 0
168 2720 0 0 4200 4200 2800 2 0
190 3072 0 0 10100 10100 7575 3 0
202 3264 0 0 7180 7180 5744 4 0
254 4096 0 0 3820 3820 3820 1 0
Total 8 45 106959 106193 47424 0
As we can see, we reduced the number of objects stored in class-4096,
because a huge number of objects which we previously forcibly stored in
class-4096 now stored in non-huge class-3264. This results in lower
memory consumption:
- zsmalloc now uses 47424 physical pages, which is less than 48787 pages
zsmalloc used before.
- objects that we store in class-3264 share zspages. That's why overall
the number of pages that both class-4096 and class-3264 consumed went
down from 10924 to 9564.
[sergey.senozhatsky.work@gmail.com: add pool param to zs_huge_class_size()]
Link: http://lkml.kernel.org/r/20180314081833.1096-3-sergey.senozhatsky@gmail.com
Link: http://lkml.kernel.org/r/20180306070639.7389-3-sergey.senozhatsky@gmail.com
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.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.c | 9 | ||||
-rw-r--r-- | drivers/block/zram/zram_drv.h | 16 |
2 files changed, 8 insertions, 17 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 0afa6c8c3857..bd38f46801d3 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -44,6 +44,11 @@ static const char *default_compressor = "lzo"; | |||
44 | 44 | ||
45 | /* Module params (documentation at end) */ | 45 | /* Module params (documentation at end) */ |
46 | static unsigned int num_devices = 1; | 46 | static unsigned int num_devices = 1; |
47 | /* | ||
48 | * Pages that compress to sizes equals or greater than this are stored | ||
49 | * uncompressed in memory. | ||
50 | */ | ||
51 | static size_t huge_class_size; | ||
47 | 52 | ||
48 | static void zram_free_page(struct zram *zram, size_t index); | 53 | static void zram_free_page(struct zram *zram, size_t index); |
49 | 54 | ||
@@ -786,6 +791,8 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize) | |||
786 | return false; | 791 | return false; |
787 | } | 792 | } |
788 | 793 | ||
794 | if (!huge_class_size) | ||
795 | huge_class_size = zs_huge_class_size(zram->mem_pool); | ||
789 | return true; | 796 | return true; |
790 | } | 797 | } |
791 | 798 | ||
@@ -965,7 +972,7 @@ compress_again: | |||
965 | return ret; | 972 | return ret; |
966 | } | 973 | } |
967 | 974 | ||
968 | if (unlikely(comp_len > max_zpage_size)) { | 975 | if (unlikely(comp_len >= huge_class_size)) { |
969 | if (zram_wb_enabled(zram) && allow_wb) { | 976 | if (zram_wb_enabled(zram) && allow_wb) { |
970 | zcomp_stream_put(zram->comp); | 977 | zcomp_stream_put(zram->comp); |
971 | ret = write_to_bdev(zram, bvec, index, bio, &element); | 978 | ret = write_to_bdev(zram, bvec, index, bio, &element); |
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 31762db861e3..d71c8000a964 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h | |||
@@ -21,22 +21,6 @@ | |||
21 | 21 | ||
22 | #include "zcomp.h" | 22 | #include "zcomp.h" |
23 | 23 | ||
24 | /*-- Configurable parameters */ | ||
25 | |||
26 | /* | ||
27 | * Pages that compress to size greater than this are stored | ||
28 | * uncompressed in memory. | ||
29 | */ | ||
30 | static const size_t max_zpage_size = PAGE_SIZE / 4 * 3; | ||
31 | |||
32 | /* | ||
33 | * NOTE: max_zpage_size must be less than or equal to: | ||
34 | * ZS_MAX_ALLOC_SIZE. Otherwise, zs_malloc() would | ||
35 | * always return failure. | ||
36 | */ | ||
37 | |||
38 | /*-- End of configurable params */ | ||
39 | |||
40 | #define SECTOR_SHIFT 9 | 24 | #define SECTOR_SHIFT 9 |
41 | #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) | 25 | #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) |
42 | #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) | 26 | #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) |