migrate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _LINUX_MIGRATE_H
  2. #define _LINUX_MIGRATE_H
  3. #include <linux/mm.h>
  4. #include <linux/mempolicy.h>
  5. #include <linux/migrate_mode.h>
  6. typedef struct page *new_page_t(struct page *, unsigned long private, int **);
  7. /*
  8. * Return values from addresss_space_operations.migratepage():
  9. * - negative errno on page migration failure;
  10. * - zero on page migration success;
  11. *
  12. * The balloon page migration introduces this special case where a 'distinct'
  13. * return code is used to flag a successful page migration to unmap_and_move().
  14. * This approach is necessary because page migration can race against balloon
  15. * deflation procedure, and for such case we could introduce a nasty page leak
  16. * if a successfully migrated balloon page gets released concurrently with
  17. * migration's unmap_and_move() wrap-up steps.
  18. */
  19. #define MIGRATEPAGE_SUCCESS 0
  20. #define MIGRATEPAGE_BALLOON_SUCCESS 1 /* special ret code for balloon page
  21. * sucessful migration case.
  22. */
  23. enum migrate_reason {
  24. MR_COMPACTION,
  25. MR_MEMORY_FAILURE,
  26. MR_MEMORY_HOTPLUG,
  27. MR_SYSCALL, /* also applies to cpusets */
  28. MR_MEMPOLICY_MBIND,
  29. MR_NUMA_MISPLACED,
  30. MR_CMA
  31. };
  32. #ifdef CONFIG_MIGRATION
  33. extern void putback_lru_pages(struct list_head *l);
  34. extern void putback_movable_pages(struct list_head *l);
  35. extern int migrate_page(struct address_space *,
  36. struct page *, struct page *, enum migrate_mode);
  37. extern int migrate_pages(struct list_head *l, new_page_t x,
  38. unsigned long private, enum migrate_mode mode, int reason);
  39. extern int fail_migrate_page(struct address_space *,
  40. struct page *, struct page *);
  41. extern int migrate_prep(void);
  42. extern int migrate_prep_local(void);
  43. extern int migrate_vmas(struct mm_struct *mm,
  44. const nodemask_t *from, const nodemask_t *to,
  45. unsigned long flags);
  46. extern void migrate_page_copy(struct page *newpage, struct page *page);
  47. extern int migrate_huge_page_move_mapping(struct address_space *mapping,
  48. struct page *newpage, struct page *page);
  49. #else
  50. static inline void putback_lru_pages(struct list_head *l) {}
  51. static inline void putback_movable_pages(struct list_head *l) {}
  52. static inline int migrate_pages(struct list_head *l, new_page_t x,
  53. unsigned long private, enum migrate_mode mode, int reason)
  54. { return -ENOSYS; }
  55. static inline int migrate_prep(void) { return -ENOSYS; }
  56. static inline int migrate_prep_local(void) { return -ENOSYS; }
  57. static inline int migrate_vmas(struct mm_struct *mm,
  58. const nodemask_t *from, const nodemask_t *to,
  59. unsigned long flags)
  60. {
  61. return -ENOSYS;
  62. }
  63. static inline void migrate_page_copy(struct page *newpage,
  64. struct page *page) {}
  65. static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
  66. struct page *newpage, struct page *page)
  67. {
  68. return -ENOSYS;
  69. }
  70. /* Possible settings for the migrate_page() method in address_operations */
  71. #define migrate_page NULL
  72. #define fail_migrate_page NULL
  73. #endif /* CONFIG_MIGRATION */
  74. #ifdef CONFIG_NUMA_BALANCING
  75. extern int migrate_misplaced_page(struct page *page, int node);
  76. extern int migrate_misplaced_page(struct page *page, int node);
  77. extern bool migrate_ratelimited(int node);
  78. #else
  79. static inline int migrate_misplaced_page(struct page *page, int node)
  80. {
  81. return -EAGAIN; /* can't migrate now */
  82. }
  83. static inline bool migrate_ratelimited(int node)
  84. {
  85. return false;
  86. }
  87. #endif /* CONFIG_NUMA_BALANCING */
  88. #if defined(CONFIG_NUMA_BALANCING) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
  89. extern int migrate_misplaced_transhuge_page(struct mm_struct *mm,
  90. struct vm_area_struct *vma,
  91. pmd_t *pmd, pmd_t entry,
  92. unsigned long address,
  93. struct page *page, int node);
  94. #else
  95. static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
  96. struct vm_area_struct *vma,
  97. pmd_t *pmd, pmd_t entry,
  98. unsigned long address,
  99. struct page *page, int node)
  100. {
  101. return -EAGAIN;
  102. }
  103. #endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/
  104. #endif /* _LINUX_MIGRATE_H */