lkml.org 
[lkml]   [2017]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] zram: better utilization of zram swap space
Date
If the length of the compressed page is greater than 75% of the PAGE_SIZE,
then the page is stored uncompressed in zram space. Zram space utilization
is improved if the threshold is 80%(5 compressed pages can be stored in
4 pages).

If the compressed length is greater than 3068 and less than 3261, pages
still can be stored in compressed form in zs_malloc class 3264.
Currently these compressed pages belong to 4096 zs malloc class.

Tested on ARM:
Before Patch:

class size obj_allocated obj_used pages_used
190 3072 3820 3819 2865
202 3264 65 63 52
254 4096 11791 11791 11791

Total 65604 64616 29504

After Patch:

class size obj_allocated obj_used pages_used
190 3072 4244 4243 3183
202 3264 1500 1499 1200
254 4096 6306 6306 6306

Total 65983 64896 26628

Signed-off-by: Gopi Sai Teja <gopi.st@samsung.com>
---
drivers/block/zram/zram_drv.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 5ece255..f7d9ddd 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -31,8 +31,12 @@ static const unsigned max_num_devices = 32;
/*
* Pages that compress to size greater than this are stored
* uncompressed in memory.
+ * 16 is zsmalloc class interval and unsigned long is extra memory
+ * used by zsmalloc to store metadata.
*/
-static const size_t max_zpage_size = PAGE_SIZE / 4 * 3;
+
+static const size_t max_zpage_size = round_down((PAGE_SIZE / 5 * 4), 16)
+ - sizeof(unsigned long);

/*
* NOTE: max_zpage_size must be less than or equal to:
--
1.9.1
\
 
 \ /
  Last update: 2017-12-07 09:27    [W:0.066 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site