[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240621054658.1220796-7-alexs@kernel.org>
Date: Fri, 21 Jun 2024 13:46:46 +0800
From: alexs@...nel.org
To: Vitaly Wool <vitaly.wool@...sulko.com>,
Miaohe Lin <linmiaohe@...wei.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
minchan@...nel.org,
willy@...radead.org,
senozhatsky@...omium.org,
david@...hat.com,
42.hyeyoo@...il.com
Cc: Alex Shi <alexs@...nel.org>
Subject: [PATCH 06/15] mm/z3fold: use zpdesc in free_z3fold_page
From: Alex Shi <alexs@...nel.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@...nel.org>
---
mm/z3fold.c | 10 ++++++----
mm/zpdesc.h | 10 ++++++++++
2 files changed, 16 insertions(+), 4 deletions(-)
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
--
2.43.0
Powered by blists - more mailing lists