blob: 1f69e4f4aa7d62fbddaaee3b26edb89d8ee2bb73 [file] [log] [blame]
From: Zi Yan <ziy@nvidia.com>
Subject: mm-page_isolation-make-page-isolation-a-standalone-bit-fix
Date: Thu, 8 May 2025 12:05:59 -0400
address Johannes comments
1. keep the original is_migrate_isolate_page()
2. move {get,set,clear}_pageblock_isolate() to mm/page_isolation.c
3. use a single version for get_pageblock_migratetype() and
get_pfnblock_migratetype().
Link: https://lkml.kernel.org/r/50BB00FF-746E-4623-8F48-F74209EDBD0A@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/mmzone.h | 6 ------
include/linux/page-isolation.h | 2 +-
include/linux/pageblock-flags.h | 24 ------------------------
mm/page_alloc.c | 25 ++++++++++---------------
mm/page_isolation.c | 17 +++++++++++++++++
5 files changed, 28 insertions(+), 46 deletions(-)
--- a/include/linux/mmzone.h~mm-page_isolation-make-page-isolation-a-standalone-bit-fix
+++ a/include/linux/mmzone.h
@@ -112,13 +112,7 @@ extern int page_group_by_mobility_disabl
#define MIGRATETYPE_MASK (BIT(PB_migratetype_bits) - 1)
#endif
-#ifdef CONFIG_MEMORY_ISOLATION
unsigned long get_pageblock_migratetype(const struct page *page);
-#else
-#define get_pageblock_migratetype(page) \
- get_pfnblock_flags_mask(page, page_to_pfn(page), MIGRATETYPE_MASK)
-
-#endif
#define folio_migratetype(folio) \
get_pageblock_migratetype(&folio->page)
--- a/include/linux/pageblock-flags.h~mm-page_isolation-make-page-isolation-a-standalone-bit-fix
+++ a/include/linux/pageblock-flags.h
@@ -112,28 +112,4 @@ static inline void set_pageblock_skip(st
}
#endif /* CONFIG_COMPACTION */
-#ifdef CONFIG_MEMORY_ISOLATION
-#define get_pageblock_isolate(page) \
- get_pfnblock_flags_mask(page, page_to_pfn(page), \
- PB_migrate_isolate_bit)
-#define clear_pageblock_isolate(page) \
- set_pfnblock_flags_mask(page, 0, page_to_pfn(page), \
- PB_migrate_isolate_bit)
-#define set_pageblock_isolate(page) \
- set_pfnblock_flags_mask(page, PB_migrate_isolate_bit, \
- page_to_pfn(page), \
- PB_migrate_isolate_bit)
-#else
-static inline bool get_pageblock_isolate(struct page *page)
-{
- return false;
-}
-static inline void clear_pageblock_isolate(struct page *page)
-{
-}
-static inline void set_pageblock_isolate(struct page *page)
-{
-}
-#endif /* CONFIG_MEMORY_ISOLATION */
-
#endif /* PAGEBLOCK_FLAGS_H */
--- a/include/linux/page-isolation.h~mm-page_isolation-make-page-isolation-a-standalone-bit-fix
+++ a/include/linux/page-isolation.h
@@ -5,7 +5,7 @@
#ifdef CONFIG_MEMORY_ISOLATION
static inline bool is_migrate_isolate_page(struct page *page)
{
- return get_pageblock_isolate(page);
+ return get_pageblock_migratetype(page) == MIGRATE_ISOLATE;
}
static inline bool is_migrate_isolate(int migratetype)
{
--- a/mm/page_alloc.c~mm-page_isolation-make-page-isolation-a-standalone-bit-fix
+++ a/mm/page_alloc.c
@@ -381,16 +381,16 @@ unsigned long get_pfnblock_flags_mask(co
return (word >> bitidx) & mask;
}
-#ifdef CONFIG_MEMORY_ISOLATION
unsigned long get_pageblock_migratetype(const struct page *page)
{
unsigned long flags;
flags = get_pfnblock_flags_mask(page, page_to_pfn(page),
MIGRATETYPE_MASK);
+#ifdef CONFIG_MEMORY_ISOLATION
if (flags & PB_migrate_isolate_bit)
return MIGRATE_ISOLATE;
-
+#endif
return flags;
}
@@ -401,19 +401,12 @@ static __always_inline int get_pfnblock_
flags = get_pfnblock_flags_mask(page, pfn,
MIGRATETYPE_MASK);
+#ifdef CONFIG_MEMORY_ISOLATION
if (flags & PB_migrate_isolate_bit)
return MIGRATE_ISOLATE;
-
+#endif
return flags;
}
-#else
-static __always_inline int get_pfnblock_migratetype(const struct page *page,
- unsigned long pfn)
-{
- return get_pfnblock_flags_mask(page, pfn, MIGRATETYPE_MASK);
-}
-
-#endif
/**
* set_pfnblock_flags_mask - Set the requested group of flags for a pageblock_nr_pages block of pages
@@ -461,11 +454,13 @@ void set_pageblock_migratetype(struct pa
migratetype = MIGRATE_UNMOVABLE;
#ifdef CONFIG_MEMORY_ISOLATION
- if (migratetype == MIGRATE_ISOLATE)
- set_pageblock_isolate(page);
- else
+ if (migratetype == MIGRATE_ISOLATE) {
+ set_pfnblock_flags_mask(page, PB_migrate_isolate_bit,
+ page_to_pfn(page), PB_migrate_isolate_bit);
+ return;
+ }
#endif
- set_pfnblock_flags_mask(page, (unsigned long)migratetype,
+ set_pfnblock_flags_mask(page, (unsigned long)migratetype,
page_to_pfn(page), MIGRATETYPE_MASK);
}
--- a/mm/page_isolation.c~mm-page_isolation-make-page-isolation-a-standalone-bit-fix
+++ a/mm/page_isolation.c
@@ -15,6 +15,23 @@
#define CREATE_TRACE_POINTS
#include <trace/events/page_isolation.h>
+static inline bool get_pageblock_isolate(struct page *page)
+{
+ return get_pfnblock_flags_mask(page, page_to_pfn(page),
+ PB_migrate_isolate_bit);
+}
+static inline void clear_pageblock_isolate(struct page *page)
+{
+ set_pfnblock_flags_mask(page, 0, page_to_pfn(page),
+ PB_migrate_isolate_bit);
+}
+static inline void set_pageblock_isolate(struct page *page)
+{
+ set_pfnblock_flags_mask(page, PB_migrate_isolate_bit,
+ page_to_pfn(page),
+ PB_migrate_isolate_bit);
+}
+
/*
* This function checks whether the range [start_pfn, end_pfn) includes
* unmovable pages or not. The range must fall into a single pageblock and
_