xref: /linux-6.15/include/linux/migrate.h (revision 779b96d2)
1 #ifndef _LINUX_MIGRATE_H
2 #define _LINUX_MIGRATE_H
3 
4 #include <linux/mm.h>
5 #include <linux/mempolicy.h>
6 
7 typedef struct page *new_page_t(struct page *, unsigned long private, int **);
8 
9 /*
10  * MIGRATE_ASYNC means never block
11  * MIGRATE_SYNC_LIGHT in the current implementation means to allow blocking
12  *	on most operations but not ->writepage as the potential stall time
13  *	is too significant
14  * MIGRATE_SYNC will block when migrating pages
15  */
16 enum migrate_mode {
17 	MIGRATE_ASYNC,
18 	MIGRATE_SYNC_LIGHT,
19 	MIGRATE_SYNC,
20 };
21 
22 #ifdef CONFIG_MIGRATION
23 #define PAGE_MIGRATION 1
24 
25 extern void putback_lru_pages(struct list_head *l);
26 extern int migrate_page(struct address_space *,
27 			struct page *, struct page *, enum migrate_mode);
28 extern int migrate_pages(struct list_head *l, new_page_t x,
29 			unsigned long private, bool offlining,
30 			enum migrate_mode mode);
31 extern int migrate_huge_pages(struct list_head *l, new_page_t x,
32 			unsigned long private, bool offlining,
33 			enum migrate_mode mode);
34 
35 extern int fail_migrate_page(struct address_space *,
36 			struct page *, struct page *);
37 
38 extern int migrate_prep(void);
39 extern int migrate_prep_local(void);
40 extern int migrate_vmas(struct mm_struct *mm,
41 		const nodemask_t *from, const nodemask_t *to,
42 		unsigned long flags);
43 extern void migrate_page_copy(struct page *newpage, struct page *page);
44 extern int migrate_huge_page_move_mapping(struct address_space *mapping,
45 				  struct page *newpage, struct page *page);
46 #else
47 #define PAGE_MIGRATION 0
48 
49 static inline void putback_lru_pages(struct list_head *l) {}
50 static inline int migrate_pages(struct list_head *l, new_page_t x,
51 		unsigned long private, bool offlining,
52 		enum migrate_mode mode) { return -ENOSYS; }
53 static inline int migrate_huge_pages(struct list_head *l, new_page_t x,
54 		unsigned long private, bool offlining,
55 		enum migrate_mode mode) { return -ENOSYS; }
56 
57 static inline int migrate_prep(void) { return -ENOSYS; }
58 static inline int migrate_prep_local(void) { return -ENOSYS; }
59 
60 static inline int migrate_vmas(struct mm_struct *mm,
61 		const nodemask_t *from, const nodemask_t *to,
62 		unsigned long flags)
63 {
64 	return -ENOSYS;
65 }
66 
67 static inline void migrate_page_copy(struct page *newpage,
68 				     struct page *page) {}
69 
70 static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
71 				  struct page *newpage, struct page *page)
72 {
73 	return -ENOSYS;
74 }
75 
76 /* Possible settings for the migrate_page() method in address_operations */
77 #define migrate_page NULL
78 #define fail_migrate_page NULL
79 
80 #endif /* CONFIG_MIGRATION */
81 #endif /* _LINUX_MIGRATE_H */
82