Skip to content

Commit e0975b2

Browse files
Michal Hockotorvalds
authored andcommitted
mm, fault_around: do not take a reference to a locked page
filemap_map_pages takes a speculative reference to each page in the range before it tries to lock that page. While this is correct it also can influence page migration which will bail out when seeing an elevated reference count. The faultaround code would bail on seeing a locked page so we can pro-actively check the PageLocked bit before page_cache_get_speculative and prevent from pointless reference count churn. Link: http://lkml.kernel.org/r/20181211142741.2607-4-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Suggested-by: Jan Kara <jack@suse.cz> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reviewed-by: David Hildenbrand <david@redhat.com> Acked-by: Hugh Dickins <hughd@google.com> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bb8965b commit e0975b2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mm/filemap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,13 @@ void filemap_map_pages(struct vm_fault *vmf,
26142614
goto next;
26152615

26162616
head = compound_head(page);
2617+
2618+
/*
2619+
* Check for a locked page first, as a speculative
2620+
* reference may adversely influence page migration.
2621+
*/
2622+
if (PageLocked(head))
2623+
goto next;
26172624
if (!page_cache_get_speculative(head))
26182625
goto next;
26192626

0 commit comments

Comments
 (0)