diff mbox series

[14/15] mm/z3fold: introduce __zpdesc_set_movable

Message ID 20240621054658.1220796-15-alexs@kernel.org (mailing list archive)
State New
Headers show
Series add zpdesc memory descriptor for zswap.zpool | expand

Commit Message

alexs@kernel.org June 21, 2024, 5:46 a.m. UTC
From: Alex Shi <alexs@kernel.org>

Add a helper __zpdesc_set_movable() for __SetPageMovable(), and use it
in callers.
Since we actually use the page.mapping for 'struct movable_operations'
pointer, we could add it into zpdesc struct now.

Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Alex Shi <alexs@kernel.org>
---
 mm/z3fold.c | 6 +++---
 mm/zpdesc.h | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/mm/z3fold.c b/mm/z3fold.c
index 7d95c0293664..35e48440c517 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -1050,11 +1050,11 @@  static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
 	}
 	if (can_sleep) {
 		zpdesc_lock(zpdesc);
-		__SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops);
+		__zpdesc_set_movable(zpdesc, &z3fold_mops);
 		zpdesc_unlock(zpdesc);
 	} else {
 		WARN_ON(!zpdesc_trylock(zpdesc));
-		__SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops);
+		__zpdesc_set_movable(zpdesc, &z3fold_mops);
 		zpdesc_unlock(zpdesc);
 	}
 	z3fold_page_lock(zhdr);
@@ -1334,7 +1334,7 @@  static int z3fold_page_migrate(struct page *newpage, struct page *page,
 		encode_handle(new_zhdr, MIDDLE);
 	set_bit(NEEDS_COMPACTING, &newzpdesc->zppage_flag);
 	new_zhdr->cpu = smp_processor_id();
-	__SetPageMovable(zpdesc_page(newzpdesc), &z3fold_mops);
+	__zpdesc_set_movable(newzpdesc, &z3fold_mops);
 	z3fold_page_unlock(new_zhdr);
 
 	queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);
diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index 9ead7a452f2a..44473382f2cc 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -73,4 +73,10 @@  static inline void zpdesc_unlock(struct zpdesc *zpdesc)
 	folio_unlock(zpdesc_folio(zpdesc));
 }
 
+static inline void __zpdesc_set_movable(struct zpdesc *zpdesc,
+					const struct movable_operations *mops)
+{
+	__SetPageMovable(zpdesc_page(zpdesc), mops);
+}
+
 #endif