1 #ifndef _LINUX_MIGRATE_H 2 #define _LINUX_MIGRATE_H 3 4 #include <linux/mm.h> 5 #include <linux/mempolicy.h> 6 #include <linux/migrate_mode.h> 7 8 typedef struct page *new_page_t(struct page *page, unsigned long private, 9 int **reason); 10 typedef void free_page_t(struct page *page, unsigned long private); 11 12 /* 13 * Return values from addresss_space_operations.migratepage(): 14 * - negative errno on page migration failure; 15 * - zero on page migration success; 16 */ 17 #define MIGRATEPAGE_SUCCESS 0 18 19 enum migrate_reason { 20 MR_COMPACTION, 21 MR_MEMORY_FAILURE, 22 MR_MEMORY_HOTPLUG, 23 MR_SYSCALL, /* also applies to cpusets */ 24 MR_MEMPOLICY_MBIND, 25 MR_NUMA_MISPLACED, 26 MR_CMA 27 }; 28 29 #ifdef CONFIG_MIGRATION 30 31 extern void putback_movable_pages(struct list_head *l); 32 extern int migrate_page(struct address_space *, 33 struct page *, struct page *, enum migrate_mode); 34 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, 35 unsigned long private, enum migrate_mode mode, int reason); 36 37 extern int migrate_prep(void); 38 extern int migrate_prep_local(void); 39 extern void migrate_page_copy(struct page *newpage, struct page *page); 40 extern int migrate_huge_page_move_mapping(struct address_space *mapping, 41 struct page *newpage, struct page *page); 42 extern int migrate_page_move_mapping(struct address_space *mapping, 43 struct page *newpage, struct page *page, 44 struct buffer_head *head, enum migrate_mode mode, 45 int extra_count); 46 #else 47 48 static inline void putback_movable_pages(struct list_head *l) {} 49 static inline int migrate_pages(struct list_head *l, new_page_t new, 50 free_page_t free, unsigned long private, enum migrate_mode mode, 51 int reason) 52 { return -ENOSYS; } 53 54 static inline int migrate_prep(void) { return -ENOSYS; } 55 static inline int migrate_prep_local(void) { return -ENOSYS; } 56 57 static inline void migrate_page_copy(struct page *newpage, 58 struct page *page) {} 59 60 static inline int migrate_huge_page_move_mapping(struct address_space *mapping, 61 struct page *newpage, struct page *page) 62 { 63 return -ENOSYS; 64 } 65 66 #endif /* CONFIG_MIGRATION */ 67 68 #ifdef CONFIG_NUMA_BALANCING 69 extern bool pmd_trans_migrating(pmd_t pmd); 70 extern int migrate_misplaced_page(struct page *page, 71 struct vm_area_struct *vma, int node); 72 #else 73 static inline bool pmd_trans_migrating(pmd_t pmd) 74 { 75 return false; 76 } 77 static inline int migrate_misplaced_page(struct page *page, 78 struct vm_area_struct *vma, int node) 79 { 80 return -EAGAIN; /* can't migrate now */ 81 } 82 #endif /* CONFIG_NUMA_BALANCING */ 83 84 #if defined(CONFIG_NUMA_BALANCING) && defined(CONFIG_TRANSPARENT_HUGEPAGE) 85 extern int migrate_misplaced_transhuge_page(struct mm_struct *mm, 86 struct vm_area_struct *vma, 87 pmd_t *pmd, pmd_t entry, 88 unsigned long address, 89 struct page *page, int node); 90 #else 91 static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm, 92 struct vm_area_struct *vma, 93 pmd_t *pmd, pmd_t entry, 94 unsigned long address, 95 struct page *page, int node) 96 { 97 return -EAGAIN; 98 } 99 #endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/ 100 101 #endif /* _LINUX_MIGRATE_H */ 102