[PATCHv2 5/6] zsmalloc: extend compaction statistics

From: Sergey Senozhatsky
Date: Wed Feb 22 2023 - 22:05:34 EST


Extend zsmalloc zs_pool_stats with a new member that
holds the number of objects pool compaction moved
between pool pages.

Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
---
include/linux/zsmalloc.h | 2 ++
mm/zsmalloc.c | 1 +
2 files changed, 3 insertions(+)

diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h
index a48cd0ffe57d..8b3fa5b4a68c 100644
--- a/include/linux/zsmalloc.h
+++ b/include/linux/zsmalloc.h
@@ -36,6 +36,8 @@ enum zs_mapmode {
struct zs_pool_stats {
/* How many pages were migrated (freed) */
atomic_long_t pages_compacted;
+ /* How many objects were migrated during compaction */
+ atomic_long_t objs_moved;
};

struct zs_pool;
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index eacf9e32da5c..f7e69df48fb0 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1815,6 +1815,7 @@ static void migrate_zspage(struct zs_pool *pool, struct size_class *class,
obj_idx++;
record_obj(handle, free_obj);
obj_free(class->size, used_obj, NULL);
+ atomic_long_inc(&pool->stats.objs_moved);
}

/* Remember last position in this iteration */
--
2.39.2.637.g21b0678d19-goog