blob: 51eac4bdc6067522e98882ca311b24bb17892171 [file] [log] [blame]
Christoph Lameterb20a3502006-03-22 00:09:12 -08001#ifndef _LINUX_MIGRATE_H
2#define _LINUX_MIGRATE_H
3
Christoph Lameterb20a3502006-03-22 00:09:12 -08004#include <linux/mm.h>
Christoph Lameter906e0be2007-05-06 14:50:20 -07005#include <linux/mempolicy.h>
Andrew Morton6536e312012-01-20 14:33:53 -08006#include <linux/migrate_mode.h>
Christoph Lameterb20a3502006-03-22 00:09:12 -08007
Christoph Lameter742755a2006-06-23 02:03:55 -07008typedef struct page *new_page_t(struct page *, unsigned long private, int **);
Christoph Lameter95a402c2006-06-23 02:03:53 -07009
Mel Gorman7b2a2d42012-10-19 14:07:31 +010010enum migrate_reason {
11 MR_COMPACTION,
12 MR_MEMORY_FAILURE,
13 MR_MEMORY_HOTPLUG,
14 MR_SYSCALL, /* also applies to cpusets */
15 MR_MEMPOLICY_MBIND,
Peter Zijlstra7039e1d2012-10-25 14:16:34 +020016 MR_NUMA_MISPLACED,
Mel Gorman7b2a2d42012-10-19 14:07:31 +010017 MR_CMA
18};
19
Christoph Lameter906e0be2007-05-06 14:50:20 -070020#ifdef CONFIG_MIGRATION
KOSAKI Motohiro64cdd542009-01-06 14:39:16 -080021
Minchan Kime13861d2010-05-24 14:31:59 -070022extern void putback_lru_pages(struct list_head *l);
Christoph Lameter2d1db3b2006-06-23 02:03:33 -070023extern int migrate_page(struct address_space *,
Mel Gormana6bc32b2012-01-12 17:19:43 -080024 struct page *, struct page *, enum migrate_mode);
Hugh Dickins62b61f62009-12-14 17:59:33 -080025extern int migrate_pages(struct list_head *l, new_page_t x,
Mel Gorman7f0f2492011-01-13 15:45:58 -080026 unsigned long private, bool offlining,
Mel Gorman7b2a2d42012-10-19 14:07:31 +010027 enum migrate_mode mode, int reason);
Aneesh Kumar K.V189ebff2012-07-31 16:42:06 -070028extern int migrate_huge_page(struct page *, new_page_t x,
Mel Gorman7f0f2492011-01-13 15:45:58 -080029 unsigned long private, bool offlining,
Mel Gormana6bc32b2012-01-12 17:19:43 -080030 enum migrate_mode mode);
Christoph Lameter95a402c2006-06-23 02:03:53 -070031
Christoph Lameter2d1db3b2006-06-23 02:03:33 -070032extern int fail_migrate_page(struct address_space *,
33 struct page *, struct page *);
Christoph Lameterb20a3502006-03-22 00:09:12 -080034
35extern int migrate_prep(void);
Mel Gorman748446b2010-05-24 14:32:27 -070036extern int migrate_prep_local(void);
Christoph Lameter7b2259b2006-06-25 05:46:48 -070037extern int migrate_vmas(struct mm_struct *mm,
38 const nodemask_t *from, const nodemask_t *to,
39 unsigned long flags);
Naoya Horiguchi290408d2010-09-08 10:19:35 +090040extern void migrate_page_copy(struct page *newpage, struct page *page);
41extern int migrate_huge_page_move_mapping(struct address_space *mapping,
42 struct page *newpage, struct page *page);
Christoph Lameterb20a3502006-03-22 00:09:12 -080043#else
KOSAKI Motohiro64cdd542009-01-06 14:39:16 -080044
Minchan Kime13861d2010-05-24 14:31:59 -070045static inline void putback_lru_pages(struct list_head *l) {}
Christoph Lameter95a402c2006-06-23 02:03:53 -070046static inline int migrate_pages(struct list_head *l, new_page_t x,
Mel Gorman7f0f2492011-01-13 15:45:58 -080047 unsigned long private, bool offlining,
Mel Gorman7b2a2d42012-10-19 14:07:31 +010048 enum migrate_mode mode, int reason) { return -ENOSYS; }
Aneesh Kumar K.V189ebff2012-07-31 16:42:06 -070049static inline int migrate_huge_page(struct page *page, new_page_t x,
Mel Gorman7f0f2492011-01-13 15:45:58 -080050 unsigned long private, bool offlining,
Mel Gormana6bc32b2012-01-12 17:19:43 -080051 enum migrate_mode mode) { return -ENOSYS; }
Christoph Lameter9bf9e892006-03-31 02:29:56 -080052
Christoph Lameterb20a3502006-03-22 00:09:12 -080053static inline int migrate_prep(void) { return -ENOSYS; }
Mel Gorman748446b2010-05-24 14:32:27 -070054static inline int migrate_prep_local(void) { return -ENOSYS; }
Christoph Lameterb20a3502006-03-22 00:09:12 -080055
Christoph Lameter7b2259b2006-06-25 05:46:48 -070056static inline int migrate_vmas(struct mm_struct *mm,
57 const nodemask_t *from, const nodemask_t *to,
58 unsigned long flags)
59{
60 return -ENOSYS;
61}
62
Naoya Horiguchi290408d2010-09-08 10:19:35 +090063static inline void migrate_page_copy(struct page *newpage,
64 struct page *page) {}
65
Naoya Horiguchi6f39ce02010-09-30 11:54:51 +090066static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
Naoya Horiguchi290408d2010-09-08 10:19:35 +090067 struct page *newpage, struct page *page)
68{
69 return -ENOSYS;
70}
71
Christoph Lameterb20a3502006-03-22 00:09:12 -080072/* Possible settings for the migrate_page() method in address_operations */
73#define migrate_page NULL
74#define fail_migrate_page NULL
75
76#endif /* CONFIG_MIGRATION */
Peter Zijlstra7039e1d2012-10-25 14:16:34 +020077
78#ifdef CONFIG_NUMA_BALANCING
79extern int migrate_misplaced_page(struct page *page, int node);
Mel Gormane14808b2012-11-19 10:59:15 +000080extern int migrate_misplaced_page(struct page *page, int node);
81extern bool migrate_ratelimited(int node);
Mel Gormanb32967f2012-11-19 12:35:47 +000082extern int migrate_misplaced_transhuge_page(struct mm_struct *mm,
83 struct vm_area_struct *vma,
84 pmd_t *pmd, pmd_t entry,
85 unsigned long address,
86 struct page *page, int node);
87
Peter Zijlstra7039e1d2012-10-25 14:16:34 +020088#else
89static inline int migrate_misplaced_page(struct page *page, int node)
90{
91 return -EAGAIN; /* can't migrate now */
92}
Mel Gormane14808b2012-11-19 10:59:15 +000093static inline bool migrate_ratelimited(int node)
94{
95 return false;
96}
Mel Gormanb32967f2012-11-19 12:35:47 +000097
98static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
99 struct vm_area_struct *vma,
100 pmd_t *pmd, pmd_t entry,
101 unsigned long address,
102 struct page *page, int node)
103{
104 return -EAGAIN;
105}
Peter Zijlstra7039e1d2012-10-25 14:16:34 +0200106#endif /* CONFIG_NUMA_BALANCING */
107
Christoph Lameterb20a3502006-03-22 00:09:12 -0800108#endif /* _LINUX_MIGRATE_H */