xref: /linux/include/linux/page-isolation.h (revision beace86e61e465dba204a268ab3f3377153a4973)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_PAGEISOLATION_H
3 #define __LINUX_PAGEISOLATION_H
4 
5 #ifdef CONFIG_MEMORY_ISOLATION
is_migrate_isolate_page(struct page * page)6 static inline bool is_migrate_isolate_page(struct page *page)
7 {
8 	return get_pageblock_migratetype(page) == MIGRATE_ISOLATE;
9 }
is_migrate_isolate(int migratetype)10 static inline bool is_migrate_isolate(int migratetype)
11 {
12 	return migratetype == MIGRATE_ISOLATE;
13 }
14 #define get_pageblock_isolate(page) \
15 	get_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate)
16 #define clear_pageblock_isolate(page) \
17 	clear_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate)
18 #define set_pageblock_isolate(page) \
19 	set_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate)
20 #else
is_migrate_isolate_page(struct page * page)21 static inline bool is_migrate_isolate_page(struct page *page)
22 {
23 	return false;
24 }
is_migrate_isolate(int migratetype)25 static inline bool is_migrate_isolate(int migratetype)
26 {
27 	return false;
28 }
get_pageblock_isolate(struct page * page)29 static inline bool get_pageblock_isolate(struct page *page)
30 {
31 	return false;
32 }
clear_pageblock_isolate(struct page * page)33 static inline void clear_pageblock_isolate(struct page *page)
34 {
35 }
set_pageblock_isolate(struct page * page)36 static inline void set_pageblock_isolate(struct page *page)
37 {
38 }
39 #endif
40 
41 /*
42  * Pageblock isolation modes:
43  * PB_ISOLATE_MODE_MEM_OFFLINE - isolate to offline (!allocate) memory
44  *				 e.g., skip over PageHWPoison() pages and
45  *				 PageOffline() pages. Unmovable pages will be
46  *				 reported in this mode.
47  * PB_ISOLATE_MODE_CMA_ALLOC   - isolate for CMA allocations
48  * PB_ISOLATE_MODE_OTHER       - isolate for other purposes
49  */
50 enum pb_isolate_mode {
51 	PB_ISOLATE_MODE_MEM_OFFLINE,
52 	PB_ISOLATE_MODE_CMA_ALLOC,
53 	PB_ISOLATE_MODE_OTHER,
54 };
55 
56 void __meminit init_pageblock_migratetype(struct page *page,
57 					  enum migratetype migratetype,
58 					  bool isolate);
59 
60 bool pageblock_isolate_and_move_free_pages(struct zone *zone, struct page *page);
61 bool pageblock_unisolate_and_move_free_pages(struct zone *zone, struct page *page);
62 
63 int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
64 			     enum pb_isolate_mode mode);
65 
66 void undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
67 
68 int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn,
69 			enum pb_isolate_mode mode);
70 #endif
71