1 #ifndef _LINUX_MIGRATE_H
2 #define _LINUX_MIGRATE_H
5 #include <linux/mempolicy.h>
6 #include <linux/migrate_mode.h>
8 typedef struct page *new_page_t(struct page *page, unsigned long private,
10 typedef void free_page_t(struct page *page, unsigned long private);
13 * Return values from addresss_space_operations.migratepage():
14 * - negative errno on page migration failure;
15 * - zero on page migration success;
17 * The balloon page migration introduces this special case where a 'distinct'
18 * return code is used to flag a successful page migration to unmap_and_move().
19 * This approach is necessary because page migration can race against balloon
20 * deflation procedure, and for such case we could introduce a nasty page leak
21 * if a successfully migrated balloon page gets released concurrently with
22 * migration's unmap_and_move() wrap-up steps.
24 #define MIGRATEPAGE_SUCCESS 0
25 #define MIGRATEPAGE_BALLOON_SUCCESS 1 /* special ret code for balloon page
26 * sucessful migration case.
32 MR_SYSCALL, /* also applies to cpusets */
38 #ifdef CONFIG_MIGRATION
40 extern void putback_movable_pages(struct list_head *l);
41 extern int migrate_page(struct address_space *,
42 struct page *, struct page *, enum migrate_mode);
43 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
44 unsigned long private, enum migrate_mode mode, int reason);
46 extern int migrate_prep(void);
47 extern int migrate_prep_local(void);
48 extern int migrate_vmas(struct mm_struct *mm,
49 const nodemask_t *from, const nodemask_t *to,
51 extern void migrate_page_copy(struct page *newpage, struct page *page);
52 extern int migrate_huge_page_move_mapping(struct address_space *mapping,
53 struct page *newpage, struct page *page);
54 extern int migrate_page_move_mapping(struct address_space *mapping,
55 struct page *newpage, struct page *page,
56 struct buffer_head *head, enum migrate_mode mode,
60 static inline void putback_movable_pages(struct list_head *l) {}
61 static inline int migrate_pages(struct list_head *l, new_page_t new,
62 free_page_t free, unsigned long private, enum migrate_mode mode,
66 static inline int migrate_prep(void) { return -ENOSYS; }
67 static inline int migrate_prep_local(void) { return -ENOSYS; }
69 static inline int migrate_vmas(struct mm_struct *mm,
70 const nodemask_t *from, const nodemask_t *to,
76 static inline void migrate_page_copy(struct page *newpage,
79 static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
80 struct page *newpage, struct page *page)
85 /* Possible settings for the migrate_page() method in address_operations */
86 #define migrate_page NULL
88 #endif /* CONFIG_MIGRATION */
90 #ifdef CONFIG_NUMA_BALANCING
91 extern bool pmd_trans_migrating(pmd_t pmd);
92 extern void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd);
93 extern int migrate_misplaced_page(struct page *page,
94 struct vm_area_struct *vma, int node);
95 extern bool migrate_ratelimited(int node);
97 static inline bool pmd_trans_migrating(pmd_t pmd)
101 static inline void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd)
104 static inline int migrate_misplaced_page(struct page *page,
105 struct vm_area_struct *vma, int node)
107 return -EAGAIN; /* can't migrate now */
109 static inline bool migrate_ratelimited(int node)
113 #endif /* CONFIG_NUMA_BALANCING */
115 #if defined(CONFIG_NUMA_BALANCING) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
116 extern int migrate_misplaced_transhuge_page(struct mm_struct *mm,
117 struct vm_area_struct *vma,
118 pmd_t *pmd, pmd_t entry,
119 unsigned long address,
120 struct page *page, int node);
122 static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
123 struct vm_area_struct *vma,
124 pmd_t *pmd, pmd_t entry,
125 unsigned long address,
126 struct page *page, int node)
130 #endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/
132 #endif /* _LINUX_MIGRATE_H */