Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton: "A large amount of MM, plenty more to come. Subsystems affected by this patch series: - tools - kthread - kbuild - scripts - ocfs2 - vfs - mm: slub, kmemleak, pagecache, gup, swap, memcg, pagemap, mremap, sparsemem, kasan, pagealloc, vmscan, compaction, mempolicy, hugetlbfs, hugetlb" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (155 commits) include/linux/huge_mm.h: check PageTail in hpage_nr_pages even when !THP mm/hugetlb: fix build failure with HUGETLB_PAGE but not HUGEBTLBFS selftests/vm: fix map_hugetlb length used for testing read and write mm/hugetlb: remove unnecessary memory fetch in PageHeadHuge() mm/hugetlb.c: clean code by removing unnecessary initialization hugetlb_cgroup: add hugetlb_cgroup reservation docs hugetlb_cgroup: add hugetlb_cgroup reservation tests hugetlb: support file_region coalescing again hugetlb_cgroup: support noreserve mappings hugetlb_cgroup: add accounting for shared mappings hugetlb: disable region_add file_region coalescing hugetlb_cgroup: add reservation accounting for private mappings mm/hugetlb_cgroup: fix hugetlb_cgroup migration hugetlb_cgroup: add interface for charge/uncharge hugetlb reservations hugetlb_cgroup: add hugetlb_cgroup reservation counter hugetlbfs: Use i_mmap_rwsem to address page fault/truncate race hugetlbfs: use i_mmap_rwsem for more pmd sharing synchronization mm/memblock.c: remove redundant assignment to variable max_addr mm: mempolicy: require at least one nodeid for MPOL_PREFERRED mm: mempolicy: use VM_BUG_ON_VMA in queue_pages_test_walk() ...
This commit is contained in:
25
mm/migrate.c
25
mm/migrate.c
@@ -1282,6 +1282,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
|
||||
int page_was_mapped = 0;
|
||||
struct page *new_hpage;
|
||||
struct anon_vma *anon_vma = NULL;
|
||||
struct address_space *mapping = NULL;
|
||||
|
||||
/*
|
||||
* Migratability of hugepages depends on architectures and their size.
|
||||
@@ -1329,18 +1330,36 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
|
||||
goto put_anon;
|
||||
|
||||
if (page_mapped(hpage)) {
|
||||
/*
|
||||
* try_to_unmap could potentially call huge_pmd_unshare.
|
||||
* Because of this, take semaphore in write mode here and
|
||||
* set TTU_RMAP_LOCKED to let lower levels know we have
|
||||
* taken the lock.
|
||||
*/
|
||||
mapping = hugetlb_page_mapping_lock_write(hpage);
|
||||
if (unlikely(!mapping))
|
||||
goto unlock_put_anon;
|
||||
|
||||
try_to_unmap(hpage,
|
||||
TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
|
||||
TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS|
|
||||
TTU_RMAP_LOCKED);
|
||||
page_was_mapped = 1;
|
||||
/*
|
||||
* Leave mapping locked until after subsequent call to
|
||||
* remove_migration_ptes()
|
||||
*/
|
||||
}
|
||||
|
||||
if (!page_mapped(hpage))
|
||||
rc = move_to_new_page(new_hpage, hpage, mode);
|
||||
|
||||
if (page_was_mapped)
|
||||
if (page_was_mapped) {
|
||||
remove_migration_ptes(hpage,
|
||||
rc == MIGRATEPAGE_SUCCESS ? new_hpage : hpage, false);
|
||||
rc == MIGRATEPAGE_SUCCESS ? new_hpage : hpage, true);
|
||||
i_mmap_unlock_write(mapping);
|
||||
}
|
||||
|
||||
unlock_put_anon:
|
||||
unlock_page(new_hpage);
|
||||
|
||||
put_anon:
|
||||
|
Reference in New Issue
Block a user