From: Christoph Lameter Hugh clarified the role of VM_LOCKED. So we can now implement page migration for mlocked pages. Allow the migration of mlocked pages. This means that try_to_unmap must unmap mlocked pages in the migration case. Signed-off-by: Christoph Lameter Acked-by: Hugh Dickins Signed-off-by: Andrew Morton --- mm/migrate.c | 10 ++++------ mm/rmap.c | 9 ++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff -puN mm/migrate.c~allow-migration-of-mlocked-pages mm/migrate.c --- devel/mm/migrate.c~allow-migration-of-mlocked-pages 2006-05-27 23:28:55.000000000 -0700 +++ devel-akpm/mm/migrate.c 2006-05-27 23:28:55.000000000 -0700 @@ -615,15 +615,13 @@ static int unmap_and_move(new_page_t get /* * Establish migration ptes or remove ptes */ - if (try_to_unmap(page, 1) != SWAP_FAIL) { - if (!page_mapped(page)) - rc = move_to_new_page(newpage, page); - } else - /* A vma has VM_LOCKED set -> permanent failure */ - rc = -EPERM; + try_to_unmap(page, 1); + if (!page_mapped(page)) + rc = move_to_new_page(newpage, page); if (rc) remove_migration_ptes(page, page); + unlock: unlock_page(page); diff -puN mm/rmap.c~allow-migration-of-mlocked-pages mm/rmap.c --- devel/mm/rmap.c~allow-migration-of-mlocked-pages 2006-05-27 23:28:55.000000000 -0700 +++ devel-akpm/mm/rmap.c 2006-05-27 23:28:55.000000000 -0700 @@ -562,9 +562,8 @@ static int try_to_unmap_one(struct page * If it's recently referenced (perhaps page_referenced * skipped over this mm) then we should reactivate it. */ - if ((vma->vm_flags & VM_LOCKED) || - (ptep_clear_flush_young(vma, address, pte) - && !migration)) { + if (!migration && ((vma->vm_flags & VM_LOCKED) || + (ptep_clear_flush_young(vma, address, pte)))) { ret = SWAP_FAIL; goto out_unmap; } @@ -771,7 +770,7 @@ static int try_to_unmap_file(struct page list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list) { - if (vma->vm_flags & VM_LOCKED) + if ((vma->vm_flags & VM_LOCKED) && !migration) continue; cursor = (unsigned long) vma->vm_private_data; if (cursor > max_nl_cursor) @@ -805,7 +804,7 @@ static int try_to_unmap_file(struct page do { list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list) { - if (vma->vm_flags & VM_LOCKED) + if ((vma->vm_flags & VM_LOCKED) && !migration) continue; cursor = (unsigned long) vma->vm_private_data; while ( cursor < max_nl_cursor && _