Commit fc3012896337c83a056c496d7cfb0072e1591181
Committed by
Linus Torvalds
1 parent
053837fce7
Exists in
master
and in
20 other branches
[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: Christoph Lameter <clameter@sgi.com> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 7 additions and 36 deletions Side-by-side Diff
mm/mempolicy.c
... | ... | @@ -185,8 +185,8 @@ |
185 | 185 | } |
186 | 186 | |
187 | 187 | static void gather_stats(struct page *, void *); |
188 | -static void migrate_page_add(struct vm_area_struct *vma, | |
189 | - struct page *page, struct list_head *pagelist, unsigned long flags); | |
188 | +static void migrate_page_add(struct page *page, struct list_head *pagelist, | |
189 | + unsigned long flags); | |
190 | 190 | |
191 | 191 | /* Scan through pages checking if pages follow certain conditions. */ |
192 | 192 | static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd, |
... | ... | @@ -228,7 +228,7 @@ |
228 | 228 | if (flags & MPOL_MF_STATS) |
229 | 229 | gather_stats(page, private); |
230 | 230 | else if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) |
231 | - migrate_page_add(vma, page, private, flags); | |
231 | + migrate_page_add(page, private, flags); | |
232 | 232 | else |
233 | 233 | break; |
234 | 234 | } while (pte++, addr += PAGE_SIZE, addr != end); |
235 | 235 | |
236 | 236 | |
237 | 237 | |
... | ... | @@ -531,42 +531,13 @@ |
531 | 531 | * page migration |
532 | 532 | */ |
533 | 533 | |
534 | -/* Check if we are the only process mapping the page in question */ | |
535 | -static inline int single_mm_mapping(struct mm_struct *mm, | |
536 | - struct address_space *mapping) | |
534 | +static void migrate_page_add(struct page *page, struct list_head *pagelist, | |
535 | + unsigned long flags) | |
537 | 536 | { |
538 | - struct vm_area_struct *vma; | |
539 | - struct prio_tree_iter iter; | |
540 | - int rc = 1; | |
541 | - | |
542 | - spin_lock(&mapping->i_mmap_lock); | |
543 | - vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, 0, ULONG_MAX) | |
544 | - if (mm != vma->vm_mm) { | |
545 | - rc = 0; | |
546 | - goto out; | |
547 | - } | |
548 | - list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list) | |
549 | - if (mm != vma->vm_mm) { | |
550 | - rc = 0; | |
551 | - goto out; | |
552 | - } | |
553 | -out: | |
554 | - spin_unlock(&mapping->i_mmap_lock); | |
555 | - return rc; | |
556 | -} | |
557 | - | |
558 | -/* | |
559 | - * Add a page to be migrated to the pagelist | |
560 | - */ | |
561 | -static void migrate_page_add(struct vm_area_struct *vma, | |
562 | - struct page *page, struct list_head *pagelist, unsigned long flags) | |
563 | -{ | |
564 | 537 | /* |
565 | - * Avoid migrating a page that is shared by others and not writable. | |
538 | + * Avoid migrating a page that is shared with others. | |
566 | 539 | */ |
567 | - if ((flags & MPOL_MF_MOVE_ALL) || !page->mapping || PageAnon(page) || | |
568 | - mapping_writably_mapped(page->mapping) || | |
569 | - single_mm_mapping(vma->vm_mm, page->mapping)) { | |
540 | + if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1) { | |
570 | 541 | if (isolate_lru_page(page)) |
571 | 542 | list_add(&page->lru, pagelist); |
572 | 543 | } |