diff mbox series

[v4,20/22] mm/zsmalloc: introduce __zpdesc_set_zsmalloc()

Message ID 20240729112534.3416707-21-alexs@kernel.org (mailing list archive)
State New
Headers show
Series mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool | expand

Commit Message

alexs@kernel.org July 29, 2024, 11:25 a.m. UTC
From: Alex Shi <alexs@kernel.org>

Add a helper __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use
it in callers to make code clear.

Signed-off-by: Alex Shi <alexs@kernel.org>
---
 mm/zpdesc.h   | 5 +++++
 mm/zsmalloc.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Vishal Moola (Oracle) Aug. 2, 2024, 7:11 p.m. UTC | #1
On Mon, Jul 29, 2024 at 07:25:32PM +0800, alexs@kernel.org wrote:
> From: Alex Shi <alexs@kernel.org>
> 
> Add a helper __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use
> it in callers to make code clear.

Definitely just fold this into the prior patch. It effectively does the
same thing.
Alex Shi Aug. 5, 2024, 8:28 a.m. UTC | #2
On 8/3/24 3:11 AM, Vishal Moola wrote:
> On Mon, Jul 29, 2024 at 07:25:32PM +0800, alexs@kernel.org wrote:
>> From: Alex Shi <alexs@kernel.org>
>>
>> Add a helper __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use
>> it in callers to make code clear.
> 
> Definitely just fold this into the prior patch. It effectively does the
> same thing.

will merge them into one.

Thanks for comments!
diff mbox series

Patch

diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index 05def4d45265..06371ce60cd1 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -119,6 +119,11 @@  static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc)
 	__ClearPageMovable(zpdesc_page(zpdesc));
 }
 
+static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc)
+{
+	__SetPageZsmalloc(zpdesc_page(zpdesc));
+}
+
 static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc)
 {
 	__ClearPageZsmalloc(zpdesc_page(zpdesc));
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index d88602fb0233..7f8e02df4e3e 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1030,7 +1030,7 @@  static struct zspage *alloc_zspage(struct zs_pool *pool,
 			cache_free_zspage(pool, zspage);
 			return NULL;
 		}
-		__SetPageZsmalloc(zpdesc_page(zpdesc));
+		__zpdesc_set_zsmalloc(zpdesc);
 
 		zpdesc_inc_zone_page_state(zpdesc);
 		zpdescs[i] = zpdesc;
@@ -1820,7 +1820,7 @@  static int zs_page_migrate(struct page *newpage, struct page *page,
 	VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc));
 
 	/* We're committed, tell the world that this is a Zsmalloc page. */
-	__SetPageZsmalloc(zpdesc_page(newzpdesc));
+	__zpdesc_set_zsmalloc(newzpdesc);
 
 	/* The page is locked, so this pointer must remain valid */
 	zspage = get_zspage(zpdesc);