migrate.h 3.1 KB
Newer Older
C
Christoph Lameter 已提交
1 2 3 4
#ifndef _LINUX_MIGRATE_H
#define _LINUX_MIGRATE_H

#include <linux/mm.h>
5
#include <linux/mempolicy.h>
6
#include <linux/migrate_mode.h>
C
Christoph Lameter 已提交
7

8
typedef struct page *new_page_t(struct page *, unsigned long private, int **);
9

10 11 12 13 14 15
enum migrate_reason {
	MR_COMPACTION,
	MR_MEMORY_FAILURE,
	MR_MEMORY_HOTPLUG,
	MR_SYSCALL,		/* also applies to cpusets */
	MR_MEMPOLICY_MBIND,
16
	MR_NUMA_MISPLACED,
17 18 19
	MR_CMA
};

20
#ifdef CONFIG_MIGRATION
21

22
extern void putback_lru_pages(struct list_head *l);
23
extern int migrate_page(struct address_space *,
24
			struct page *, struct page *, enum migrate_mode);
25
extern int migrate_pages(struct list_head *l, new_page_t x,
26
			unsigned long private, bool offlining,
27
			enum migrate_mode mode, int reason);
28
extern int migrate_huge_page(struct page *, new_page_t x,
29
			unsigned long private, bool offlining,
30
			enum migrate_mode mode);
31

32 33
extern int fail_migrate_page(struct address_space *,
			struct page *, struct page *);
C
Christoph Lameter 已提交
34 35

extern int migrate_prep(void);
36
extern int migrate_prep_local(void);
37 38 39
extern int migrate_vmas(struct mm_struct *mm,
		const nodemask_t *from, const nodemask_t *to,
		unsigned long flags);
N
Naoya Horiguchi 已提交
40 41 42
extern void migrate_page_copy(struct page *newpage, struct page *page);
extern int migrate_huge_page_move_mapping(struct address_space *mapping,
				  struct page *newpage, struct page *page);
C
Christoph Lameter 已提交
43
#else
44

45
static inline void putback_lru_pages(struct list_head *l) {}
46
static inline int migrate_pages(struct list_head *l, new_page_t x,
47
		unsigned long private, bool offlining,
48
		enum migrate_mode mode, int reason) { return -ENOSYS; }
49
static inline int migrate_huge_page(struct page *page, new_page_t x,
50
		unsigned long private, bool offlining,
51
		enum migrate_mode mode) { return -ENOSYS; }
52

C
Christoph Lameter 已提交
53
static inline int migrate_prep(void) { return -ENOSYS; }
54
static inline int migrate_prep_local(void) { return -ENOSYS; }
C
Christoph Lameter 已提交
55

56 57 58 59 60 61 62
static inline int migrate_vmas(struct mm_struct *mm,
		const nodemask_t *from, const nodemask_t *to,
		unsigned long flags)
{
	return -ENOSYS;
}

N
Naoya Horiguchi 已提交
63 64 65
static inline void migrate_page_copy(struct page *newpage,
				     struct page *page) {}

66
static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
N
Naoya Horiguchi 已提交
67 68 69 70 71
				  struct page *newpage, struct page *page)
{
	return -ENOSYS;
}

C
Christoph Lameter 已提交
72 73 74 75 76
/* Possible settings for the migrate_page() method in address_operations */
#define migrate_page NULL
#define fail_migrate_page NULL

#endif /* CONFIG_MIGRATION */
77 78 79

#ifdef CONFIG_NUMA_BALANCING
extern int migrate_misplaced_page(struct page *page, int node);
80 81
extern int migrate_misplaced_page(struct page *page, int node);
extern bool migrate_ratelimited(int node);
82 83 84 85 86 87
extern int migrate_misplaced_transhuge_page(struct mm_struct *mm,
			struct vm_area_struct *vma,
			pmd_t *pmd, pmd_t entry,
			unsigned long address,
			struct page *page, int node);

88 89 90 91 92
#else
static inline int migrate_misplaced_page(struct page *page, int node)
{
	return -EAGAIN; /* can't migrate now */
}
93 94 95 96
static inline bool migrate_ratelimited(int node)
{
	return false;
}
97 98 99 100 101 102 103 104 105

static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
			struct vm_area_struct *vma,
			pmd_t *pmd, pmd_t entry,
			unsigned long address,
			struct page *page, int node)
{
	return -EAGAIN;
}
106 107
#endif /* CONFIG_NUMA_BALANCING */

C
Christoph Lameter 已提交
108
#endif /* _LINUX_MIGRATE_H */