lkml.org 
[lkml]   [2019]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/3] zsmalloc: add compaction and huge class callbacks
Add compaction callbacks for zpool compaction API extension.
Add huge_class_size callback too to be fully aligned.

With these in place, we can proceed with ZRAM modification
to use the universal (zpool) API.

Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
---
mm/zsmalloc.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2b2b9aae8a3c..43f43272b998 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -437,11 +437,29 @@ static void zs_zpool_unmap(void *pool, unsigned long handle)
zs_unmap_object(pool, handle);
}

+static unsigned long zs_zpool_compact(void *pool)
+{
+ return zs_compact(pool);
+}
+
+static unsigned long zs_zpool_get_compacted(void *pool)
+{
+ struct zs_pool_stats stats;
+
+ zs_pool_stats(pool, &stats);
+ return stats.pages_compacted;
+}
+
static u64 zs_zpool_total_size(void *pool)
{
return zs_get_total_pages(pool) << PAGE_SHIFT;
}

+static size_t zs_zpool_huge_class_size(void *pool)
+{
+ return zs_huge_class_size(pool);
+}
+
static struct zpool_driver zs_zpool_driver = {
.type = "zsmalloc",
.owner = THIS_MODULE,
@@ -453,6 +471,9 @@ static struct zpool_driver zs_zpool_driver = {
.map = zs_zpool_map,
.unmap = zs_zpool_unmap,
.total_size = zs_zpool_total_size,
+ .compact = zs_zpool_compact,
+ .get_num_compacted = zs_zpool_get_compacted,
+ .huge_class_size = zs_zpool_huge_class_size,
};

MODULE_ALIAS("zpool-zsmalloc");
--
2.20.1
\
 
 \ /
  Last update: 2019-10-10 22:12    [W:0.080 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site