2006-03-22 16:09:12 +08:00
|
|
|
#ifndef _LINUX_MIGRATE_H
|
|
|
|
#define _LINUX_MIGRATE_H
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
2007-05-07 05:50:20 +08:00
|
|
|
#include <linux/mempolicy.h>
|
2006-03-22 16:09:12 +08:00
|
|
|
|
2006-06-23 17:03:55 +08:00
|
|
|
typedef struct page *new_page_t(struct page *, unsigned long private, int **);
|
2006-06-23 17:03:53 +08:00
|
|
|
|
2012-01-13 09:19:43 +08:00
|
|
|
/*
|
|
|
|
* MIGRATE_ASYNC means never block
|
|
|
|
* MIGRATE_SYNC_LIGHT in the current implementation means to allow blocking
|
|
|
|
* on most operations but not ->writepage as the potential stall time
|
|
|
|
* is too significant
|
|
|
|
* MIGRATE_SYNC will block when migrating pages
|
|
|
|
*/
|
|
|
|
enum migrate_mode {
|
|
|
|
MIGRATE_ASYNC,
|
|
|
|
MIGRATE_SYNC_LIGHT,
|
|
|
|
MIGRATE_SYNC,
|
|
|
|
};
|
|
|
|
|
2007-05-07 05:50:20 +08:00
|
|
|
#ifdef CONFIG_MIGRATION
|
2009-01-07 06:39:16 +08:00
|
|
|
#define PAGE_MIGRATION 1
|
|
|
|
|
2010-05-25 05:31:59 +08:00
|
|
|
extern void putback_lru_pages(struct list_head *l);
|
2006-06-23 17:03:33 +08:00
|
|
|
extern int migrate_page(struct address_space *,
|
2012-01-13 09:19:43 +08:00
|
|
|
struct page *, struct page *, enum migrate_mode);
|
ksm: memory hotremove migration only
The previous patch enables page migration of ksm pages, but that soon gets
into trouble: not surprising, since we're using the ksm page lock to lock
operations on its stable_node, but page migration switches the page whose
lock is to be used for that. Another layer of locking would fix it, but
do we need that yet?
Do we actually need page migration of ksm pages? Yes, memory hotremove
needs to offline sections of memory: and since we stopped allocating ksm
pages with GFP_HIGHUSER, they will tend to be GFP_HIGHUSER_MOVABLE
candidates for migration.
But KSM is currently unconscious of NUMA issues, happily merging pages
from different NUMA nodes: at present the rule must be, not to use
MADV_MERGEABLE where you care about NUMA. So no, NUMA page migration of
ksm pages does not make sense yet.
So, to complete support for ksm swapping we need to make hotremove safe.
ksm_memory_callback() take ksm_thread_mutex when MEM_GOING_OFFLINE and
release it when MEM_OFFLINE or MEM_CANCEL_OFFLINE. But if mapped pages
are freed before migration reaches them, stable_nodes may be left still
pointing to struct pages which have been removed from the system: the
stable_node needs to identify a page by pfn rather than page pointer, then
it can safely prune them when MEM_OFFLINE.
And make NUMA migration skip PageKsm pages where it skips PageReserved.
But it's only when we reach unmap_and_move() that the page lock is taken
and we can be sure that raised pagecount has prevented a PageAnon from
being upgraded: so add offlining arg to migrate_pages(), to migrate ksm
page when offlining (has sufficient locking) but reject it otherwise.
Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Izik Eidus <ieidus@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Wright <chrisw@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-15 09:59:33 +08:00
|
|
|
extern int migrate_pages(struct list_head *l, new_page_t x,
|
2011-01-14 07:45:58 +08:00
|
|
|
unsigned long private, bool offlining,
|
2012-01-13 09:19:43 +08:00
|
|
|
enum migrate_mode mode);
|
2010-09-08 09:19:35 +08:00
|
|
|
extern int migrate_huge_pages(struct list_head *l, new_page_t x,
|
2011-01-14 07:45:58 +08:00
|
|
|
unsigned long private, bool offlining,
|
2012-01-13 09:19:43 +08:00
|
|
|
enum migrate_mode mode);
|
2006-06-23 17:03:53 +08:00
|
|
|
|
2006-06-23 17:03:33 +08:00
|
|
|
extern int fail_migrate_page(struct address_space *,
|
|
|
|
struct page *, struct page *);
|
2006-03-22 16:09:12 +08:00
|
|
|
|
|
|
|
extern int migrate_prep(void);
|
2010-05-25 05:32:27 +08:00
|
|
|
extern int migrate_prep_local(void);
|
2006-06-25 20:46:48 +08:00
|
|
|
extern int migrate_vmas(struct mm_struct *mm,
|
|
|
|
const nodemask_t *from, const nodemask_t *to,
|
|
|
|
unsigned long flags);
|
2010-09-08 09:19:35 +08:00
|
|
|
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);
|
2006-03-22 16:09:12 +08:00
|
|
|
#else
|
2009-01-07 06:39:16 +08:00
|
|
|
#define PAGE_MIGRATION 0
|
|
|
|
|
2010-05-25 05:31:59 +08:00
|
|
|
static inline void putback_lru_pages(struct list_head *l) {}
|
2006-06-23 17:03:53 +08:00
|
|
|
static inline int migrate_pages(struct list_head *l, new_page_t x,
|
2011-01-14 07:45:58 +08:00
|
|
|
unsigned long private, bool offlining,
|
2012-01-13 09:19:43 +08:00
|
|
|
enum migrate_mode mode) { return -ENOSYS; }
|
2010-09-08 09:19:35 +08:00
|
|
|
static inline int migrate_huge_pages(struct list_head *l, new_page_t x,
|
2011-01-14 07:45:58 +08:00
|
|
|
unsigned long private, bool offlining,
|
2012-01-13 09:19:43 +08:00
|
|
|
enum migrate_mode mode) { return -ENOSYS; }
|
2006-03-31 18:29:56 +08:00
|
|
|
|
2006-03-22 16:09:12 +08:00
|
|
|
static inline int migrate_prep(void) { return -ENOSYS; }
|
2010-05-25 05:32:27 +08:00
|
|
|
static inline int migrate_prep_local(void) { return -ENOSYS; }
|
2006-03-22 16:09:12 +08:00
|
|
|
|
2006-06-25 20:46:48 +08:00
|
|
|
static inline int migrate_vmas(struct mm_struct *mm,
|
|
|
|
const nodemask_t *from, const nodemask_t *to,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2010-09-08 09:19:35 +08:00
|
|
|
static inline void migrate_page_copy(struct page *newpage,
|
|
|
|
struct page *page) {}
|
|
|
|
|
2010-09-30 10:54:51 +08:00
|
|
|
static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
|
2010-09-08 09:19:35 +08:00
|
|
|
struct page *newpage, struct page *page)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2006-03-22 16:09:12 +08:00
|
|
|
/* Possible settings for the migrate_page() method in address_operations */
|
|
|
|
#define migrate_page NULL
|
|
|
|
#define fail_migrate_page NULL
|
|
|
|
|
|
|
|
#endif /* CONFIG_MIGRATION */
|
|
|
|
#endif /* _LINUX_MIGRATE_H */
|