Commit fc301289 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

[PATCH] Simplify migrate_page_add

Simplify migrate_page_add after feedback from Hugh.  This also allows us to
drop one parameter from migrate_page_add.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 053837fc
...@@ -185,8 +185,8 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes) ...@@ -185,8 +185,8 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes)
} }
static void gather_stats(struct page *, void *); static void gather_stats(struct page *, void *);
static void migrate_page_add(struct vm_area_struct *vma, static void migrate_page_add(struct page *page, struct list_head *pagelist,
struct page *page, struct list_head *pagelist, unsigned long flags); unsigned long flags);
/* Scan through pages checking if pages follow certain conditions. */ /* Scan through pages checking if pages follow certain conditions. */
static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd, static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
...@@ -228,7 +228,7 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd, ...@@ -228,7 +228,7 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
if (flags & MPOL_MF_STATS) if (flags & MPOL_MF_STATS)
gather_stats(page, private); gather_stats(page, private);
else if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) else if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
migrate_page_add(vma, page, private, flags); migrate_page_add(page, private, flags);
else else
break; break;
} while (pte++, addr += PAGE_SIZE, addr != end); } while (pte++, addr += PAGE_SIZE, addr != end);
...@@ -531,42 +531,13 @@ long do_get_mempolicy(int *policy, nodemask_t *nmask, ...@@ -531,42 +531,13 @@ long do_get_mempolicy(int *policy, nodemask_t *nmask,
* page migration * page migration
*/ */
/* Check if we are the only process mapping the page in question */ static void migrate_page_add(struct page *page, struct list_head *pagelist,
static inline int single_mm_mapping(struct mm_struct *mm, unsigned long flags)
struct address_space *mapping)
{
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int rc = 1;
spin_lock(&mapping->i_mmap_lock);
vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, 0, ULONG_MAX)
if (mm != vma->vm_mm) {
rc = 0;
goto out;
}
list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list)
if (mm != vma->vm_mm) {
rc = 0;
goto out;
}
out:
spin_unlock(&mapping->i_mmap_lock);
return rc;
}
/*
* Add a page to be migrated to the pagelist
*/
static void migrate_page_add(struct vm_area_struct *vma,
struct page *page, struct list_head *pagelist, unsigned long flags)
{ {
/* /*
* Avoid migrating a page that is shared by others and not writable. * Avoid migrating a page that is shared with others.
*/ */
if ((flags & MPOL_MF_MOVE_ALL) || !page->mapping || PageAnon(page) || if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1) {
mapping_writably_mapped(page->mapping) ||
single_mm_mapping(vma->vm_mm, page->mapping)) {
if (isolate_lru_page(page)) if (isolate_lru_page(page))
list_add(&page->lru, pagelist); list_add(&page->lru, pagelist);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment