[RFC PATCH v2 12/21] mm/zsmalloc: convert obj_to_page() and zs_free() to use zsdesc

From: Hyeonggon Yoo
Date: Thu Jul 13 2023 - 00:22:27 EST


Convert obj_to_page() to obj_to_zsdesc() and also convert its user
zs_free() to use zsdesc.

Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
---
mm/zsmalloc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index c8c3039a751a..5141a0c72c61 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -915,10 +915,10 @@ static void obj_to_location(unsigned long obj, struct zsdesc **zsdesc,
*obj_idx = (obj & OBJ_INDEX_MASK);
}

-static void obj_to_page(unsigned long obj, struct page **page)
+static void obj_to_zsdesc(unsigned long obj, struct zsdesc **zsdesc)
{
obj >>= OBJ_TAG_BITS;
- *page = pfn_to_page(obj >> OBJ_INDEX_BITS);
+ *zsdesc = pfn_zsdesc(obj >> OBJ_INDEX_BITS);
}

/**
@@ -1593,7 +1593,7 @@ static void obj_free(int class_size, unsigned long obj)
void zs_free(struct zs_pool *pool, unsigned long handle)
{
struct zspage *zspage;
- struct page *f_page;
+ struct zsdesc *f_zsdesc;
unsigned long obj;
struct size_class *class;
int fullness;
@@ -1607,8 +1607,8 @@ void zs_free(struct zs_pool *pool, unsigned long handle)
*/
spin_lock(&pool->lock);
obj = handle_to_obj(handle);
- obj_to_page(obj, &f_page);
- zspage = get_zspage(f_page);
+ obj_to_zsdesc(obj, &f_zsdesc);
+ zspage = get_zspage(zsdesc_page(f_zsdesc));
class = zspage_class(pool, zspage);

class_stat_dec(class, ZS_OBJS_INUSE, 1);
--
2.41.0