The patch titled Subject: zram: drop max_zpage_size and use zs_huge_class_size() has been added to the -mm tree. Its filename is zram-drop-max_zpage_size-and-use-zs_huge_class_size.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/zram-drop-max_zpage_size-and-use-zs_huge_class_size.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/zram-drop-max_zpage_size-and-use-zs_huge_class_size.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Sergey Senozhatsky <sergey.senozhatsky.work@xxxxxxxxx> Subject: zram: drop max_zpage_size and use zs_huge_class_size() This patch removes ZRAM's enforced "huge object" value and uses 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. Link: http://lkml.kernel.org/r/20180306070639.7389-3-sergey.senozhatsky@xxxxxxxxx Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/block/zram/zram_drv.c | 9 ++++++++- drivers/block/zram/zram_drv.h | 16 ---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff -puN drivers/block/zram/zram_drv.c~zram-drop-max_zpage_size-and-use-zs_huge_class_size drivers/block/zram/zram_drv.c --- a/drivers/block/zram/zram_drv.c~zram-drop-max_zpage_size-and-use-zs_huge_class_size +++ a/drivers/block/zram/zram_drv.c @@ -44,6 +44,11 @@ static const char *default_compressor = /* Module params (documentation at end) */ static unsigned int num_devices = 1; +/* + * Pages that compress to sizes equals or greater than this are stored + * uncompressed in memory. + */ +static size_t huge_class_size; static void zram_free_page(struct zram *zram, size_t index); @@ -786,6 +791,8 @@ static bool zram_meta_alloc(struct zram return false; } + if (!huge_class_size) + huge_class_size = zs_huge_class_size(); return true; } @@ -965,7 +972,7 @@ compress_again: return ret; } - if (unlikely(comp_len > max_zpage_size)) { + if (unlikely(comp_len >= huge_class_size)) { if (zram_wb_enabled(zram) && allow_wb) { zcomp_stream_put(zram->comp); ret = write_to_bdev(zram, bvec, index, bio, &element); diff -puN drivers/block/zram/zram_drv.h~zram-drop-max_zpage_size-and-use-zs_huge_class_size drivers/block/zram/zram_drv.h --- a/drivers/block/zram/zram_drv.h~zram-drop-max_zpage_size-and-use-zs_huge_class_size +++ a/drivers/block/zram/zram_drv.h @@ -21,22 +21,6 @@ #include "zcomp.h" -/*-- Configurable parameters */ - -/* - * Pages that compress to size greater than this are stored - * uncompressed in memory. - */ -static const size_t max_zpage_size = PAGE_SIZE / 4 * 3; - -/* - * NOTE: max_zpage_size must be less than or equal to: - * ZS_MAX_ALLOC_SIZE. Otherwise, zs_malloc() would - * always return failure. - */ - -/*-- End of configurable params */ - #define SECTOR_SHIFT 9 #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) _ Patches currently in -mm which might be from sergey.senozhatsky.work@xxxxxxxxx are zsmalloc-introduce-zs_huge_class_size-function.patch zram-drop-max_zpage_size-and-use-zs_huge_class_size.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html