mm: munlock: manual pte walk in fast path instead of follow_page_mask()
authorVlastimil Babka <[email protected]>
Wed, 11 Sep 2013 21:22:35 +0000 (14:22 -0700)
committerLinus Torvalds <[email protected]>
Wed, 11 Sep 2013 22:58:01 +0000 (15:58 -0700)
commit7a8010cd36273ff5f6fea5201ef9232f30cebbd9
tree3805f3d9a8a1f1c1c555ef31bc1bdb51fb51e33e
parent5b40998ae35cf64561868370e6c9f3d3e94b6bf7
mm: munlock: manual pte walk in fast path instead of follow_page_mask()

Currently munlock_vma_pages_range() calls follow_page_mask() to obtain
each individual struct page.  This entails repeated full page table
translations and page table lock taken for each page separately.

This patch avoids the costly follow_page_mask() where possible, by
iterating over ptes within single pmd under single page table lock.  The
first pte is obtained by get_locked_pte() for non-THP page acquired by the
initial follow_page_mask().  The rest of the on-stack pagevec for munlock
is filled up using pte_walk as long as pte_present() and vm_normal_page()
are sufficient to obtain the struct page.

After this patch, a 14% speedup was measured for munlocking a 56GB large
memory area with THP disabled.

Signed-off-by: Vlastimil Babka <[email protected]>
Cc: Jörn Engel <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/mm.h
mm/mlock.c