migrate.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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, bool offlining,
  39. enum migrate_mode mode, int reason);
  40. extern int migrate_huge_page(struct page *, new_page_t x,
  41. unsigned long private, bool offlining,
  42. enum migrate_mode mode);
  43. extern int fail_migrate_page(struct address_space *,
  44. struct page *, struct page *);
  45. extern int migrate_prep(void);
  46. extern int migrate_prep_local(void);
  47. extern int migrate_vmas(struct mm_struct *mm,
  48. const nodemask_t *from, const nodemask_t *to,
  49. unsigned long flags);
  50. extern void migrate_page_copy(struct page *newpage, struct page *page);
  51. extern int migrate_huge_page_move_mapping(struct address_space *mapping,
  52. struct page *newpage, struct page *page);
  53. #else
  54. static inline void putback_lru_pages(struct list_head *l) {}
  55. static inline void putback_movable_pages(struct list_head *l) {}
  56. static inline int migrate_pages(struct list_head *l, new_page_t x,
  57. unsigned long private, bool offlining,
  58. enum migrate_mode mode, int reason) { return -ENOSYS; }
  59. static inline int migrate_huge_page(struct page *page, new_page_t x,
  60. unsigned long private, bool offlining,
  61. enum migrate_mode mode) { return -ENOSYS; }
  62. static inline int migrate_prep(void) { return -ENOSYS; }
  63. static inline int migrate_prep_local(void) { return -ENOSYS; }
  64. static inline int migrate_vmas(struct mm_struct *mm,
  65. const nodemask_t *from, const nodemask_t *to,
  66. unsigned long flags)
  67. {
  68. return -ENOSYS;
  69. }
  70. static inline void migrate_page_copy(struct page *newpage,
  71. struct page *page) {}
  72. static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
  73. struct page *newpage, struct page *page)
  74. {
  75. return -ENOSYS;
  76. }
  77. /* Possible settings for the migrate_page() method in address_operations */
  78. #define migrate_page NULL
  79. #define fail_migrate_page NULL
  80. #endif /* CONFIG_MIGRATION */
  81. #ifdef CONFIG_NUMA_BALANCING
  82. extern int migrate_misplaced_page(struct page *page, int node);
  83. extern int migrate_misplaced_page(struct page *page, int node);
  84. extern bool migrate_ratelimited(int node);
  85. #else
  86. static inline int migrate_misplaced_page(struct page *page, int node)
  87. {
  88. return -EAGAIN; /* can't migrate now */
  89. }
  90. static inline bool migrate_ratelimited(int node)
  91. {
  92. return false;
  93. }
  94. #endif /* CONFIG_NUMA_BALANCING */
  95. #if defined(CONFIG_NUMA_BALANCING) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
  96. extern int migrate_misplaced_transhuge_page(struct mm_struct *mm,
  97. struct vm_area_struct *vma,
  98. pmd_t *pmd, pmd_t entry,
  99. unsigned long address,
  100. struct page *page, int node);
  101. #else
  102. static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
  103. struct vm_area_struct *vma,
  104. pmd_t *pmd, pmd_t entry,
  105. unsigned long address,
  106. struct page *page, int node)
  107. {
  108. return -EAGAIN;
  109. }
  110. #endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/
  111. #endif /* _LINUX_MIGRATE_H */