linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Matthew Wilcox <willy@infradead.org>,
	Vishal Moola <vishal.moola@gmail.com>,
	Alex Shi <seakeel@gmail.com>, Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Alex Shi <alexs@kernel.org>
Subject: [PATCH v9 mm-unstable 18/18] mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc()
Date: Tue, 17 Dec 2024 00:04:49 +0900	[thread overview]
Message-ID: <20241216150450.1228021-19-42.hyeyoo@gmail.com> (raw)
In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com>

From: Alex Shi <alexs@kernel.org>

Add helper __zpdesc_clear_zsmalloc() for __ClearPageZsmalloc(),
__zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use them in
callers.

[42.hyeyoo: keep reset_zpdesc() to use struct page]
Signed-off-by: Alex Shi <alexs@kernel.org>
Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
 mm/zpdesc.h   | 10 ++++++++++
 mm/zsmalloc.c |  6 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index fa80c50993c6..2da58339ac5b 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -155,6 +155,16 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc,
 	__SetPageMovable(zpdesc_page(zpdesc), mops);
 }
 
+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));
+}
+
 static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc)
 {
 	return PageIsolated(zpdesc_page(zpdesc));
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 3a841e16746e..dae32e051779 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1001,13 +1001,13 @@ static struct zspage *alloc_zspage(struct zs_pool *pool,
 		if (!zpdesc) {
 			while (--i >= 0) {
 				zpdesc_dec_zone_page_state(zpdescs[i]);
-				__ClearPageZsmalloc(zpdesc_page(zpdescs[i]));
+				__zpdesc_clear_zsmalloc(zpdescs[i]);
 				free_zpdesc(zpdescs[i]);
 			}
 			cache_free_zspage(pool, zspage);
 			return NULL;
 		}
-		__SetPageZsmalloc(zpdesc_page(zpdesc));
+		__zpdesc_set_zsmalloc(zpdesc);
 
 		zpdesc_inc_zone_page_state(zpdesc);
 		zpdescs[i] = zpdesc;
@@ -1786,7 +1786,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);
-- 
2.43.5



  parent reply	other threads:[~2024-12-16 15:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 15:04 [PATCH v9 mm-unstable 00/18] Add zpdesc memory descriptor for zswap.zpool Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 01/18] mm/zsmalloc: add " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 02/18] mm/zsmalloc: use zpdesc in trylock_zspage()/lock_zspage() Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 03/18] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 04/18] mm/zsmalloc: add and use pfn/zpdesc seeking funcs Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 05/18] mm/zsmalloc: convert obj_malloc() to use zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 06/18] mm/zsmalloc: convert create_page_chain() and its users " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 07/18] mm/zsmalloc: convert obj_allocated() and related helpers " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 08/18] mm/zsmalloc: convert init_zspage() " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 09/18] mm/zsmalloc: convert obj_to_page() and zs_free() " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 10/18] mm/zsmalloc: add two helpers for zs_page_migrate() and make it " Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 11/18] mm/zsmalloc: convert reset_page to reset_zpdesc Hyeonggon Yoo
2025-01-10  4:43   ` Matthew Wilcox
2025-01-10  6:08     ` Hyeonggon Yoo
2025-01-11  1:32       ` Andrew Morton
2025-01-13 15:29         ` [PATCH v9 mm-unstable 19/19] mm/zsmalloc: reset zpdesc fields in reset_zpdesc() Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 12/18] mm/zsmalloc: convert __free_zspage() to use zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 13/18] mm/zsmalloc: convert location_to_obj() to take zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 14/18] mm/zsmalloc: convert migrate_zspage() to use zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 15/18] mm/zsmalloc: convert get_zspage() to take zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 16/18] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Hyeonggon Yoo
2024-12-16 15:04 ` [PATCH v9 mm-unstable 17/18] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Hyeonggon Yoo
2024-12-16 15:04 ` Hyeonggon Yoo [this message]
2024-12-26  1:54 ` [PATCH v9 mm-unstable 00/18] Add zpdesc memory descriptor for zswap.zpool Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241216150450.1228021-19-42.hyeyoo@gmail.com \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexs@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=seakeel@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=vishal.moola@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox