Index: linux-2.6.14-rc4-mm1/mm/mempolicy.c =================================================================== --- linux-2.6.14-rc4-mm1.orig/mm/mempolicy.c 2005-10-17 13:30:44.000000000 -0700 +++ linux-2.6.14-rc4-mm1/mm/mempolicy.c 2005-10-17 15:23:08.000000000 -0700 @@ -329,6 +329,36 @@ check_range(struct mm_struct *mm, unsign return first; } +/* + * Main entry point to page migration. + * For now move_pages simply swaps out the pages from nodes that are in + * the source set but not in the target set. In the future, we would + * want a function that moves pages between the two nodesets in such + * a way as to preserve the physical layout as much as possible. + * + * Returns the number of page that could not be moved. + */ +int move_pages(struct mm_struct *mm, unsigned long start, unsigned long end, + nodemask_t *from_nodes, nodemask_t *to_nodes) +{ + LIST_HEAD(pagelist); + int count = 0; + nodemask_t nodes; + + nodes_andnot(nodes, *from_nodes, *to_nodes); + nodes_complement(nodes, nodes); + + down_read(&mm->mmap_sem); + check_range(mm, start, end, &nodes, MPOL_MF_MOVE, &pagelist); + if (!list_empty(&pagelist)) { + swapout_pages(&pagelist); + if (!list_empty(&pagelist)) + count = putback_lru_pages(&pagelist); + } + up_read(&mm->mmap_sem); + return count; +} + /* Apply policy to a single VMA */ static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new) { Index: linux-2.6.14-rc4-mm1/include/linux/swap.h =================================================================== --- linux-2.6.14-rc4-mm1.orig/include/linux/swap.h 2005-10-17 11:36:28.000000000 -0700 +++ linux-2.6.14-rc4-mm1/include/linux/swap.h 2005-10-17 14:38:15.000000000 -0700 @@ -175,6 +175,10 @@ extern int try_to_free_pages(struct zone extern int zone_reclaim(struct zone *, unsigned int, unsigned int); extern int shrink_all_memory(int); extern int vm_swappiness; +extern int isolate_lru_page(struct page *p, struct list_head *l); +extern int swapout_pages(struct list_head *l); +extern int putback_lru_pages(struct list_head *l); +extern int move_pages(struct list_head *l, struct list_head *n, int node); #ifdef CONFIG_MMU /* linux/mm/shmem.c */ @@ -255,10 +259,6 @@ struct backing_dev_info; extern spinlock_t swap_lock; -extern int isolate_lru_page(struct page *p, struct list_head *l); -extern int swapout_pages(struct list_head *l); -extern int putback_lru_pages(struct list_head *l); - /* linux/mm/thrash.c */ extern struct mm_struct * swap_token_mm; extern unsigned long swap_token_default_timeout;