diff mbox series

[06/15] mm/z3fold: use zpdesc in free_z3fold_page

Message ID 20240621054658.1220796-7-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>

Convert page to zpdesc in free_z3fold_page and introduce new helper
zpdesc_lock/unlock. this patch could saves about 10kbytes on object
file size.

Signed-off-by: Alex Shi <alexs@kernel.org>
---
 mm/z3fold.c | 10 ++++++----
 mm/zpdesc.h | 10 ++++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/mm/z3fold.c b/mm/z3fold.c
index cd1332243c62..c3c740b42052 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -351,12 +351,14 @@  static struct z3fold_header *init_z3fold_page(struct page *page, bool headless,
 /* Resets the struct page fields and frees the page */
 static void free_z3fold_page(struct page *page, bool headless)
 {
+	struct zpdesc *zpdesc = page_zpdesc(page);
+
 	if (!headless) {
-		lock_page(page);
-		__ClearPageMovable(page);
-		unlock_page(page);
+		zpdesc_lock(zpdesc);
+		__ClearPageMovable(zpdesc_page(zpdesc));
+		zpdesc_unlock(zpdesc);
 	}
-	__free_page(page);
+	__free_page(zpdesc_page(zpdesc));
 }
 
 /* Helper function to build the index */
diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index 7fde29645331..06cfd33de330 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -58,4 +58,14 @@  static inline void zpdesc_put(struct zpdesc *zpdesc)
 	folio_put(zpdesc_folio(zpdesc));
 }
 
+static inline void zpdesc_lock(struct zpdesc *zpdesc)
+{
+	folio_lock(zpdesc_folio(zpdesc));
+}
+
+static inline void zpdesc_unlock(struct zpdesc *zpdesc)
+{
+	folio_unlock(zpdesc_folio(zpdesc));
+}
+
 #endif