On Tue 20-11-18 17:07:15, Kirill A. Shutemov wrote: > On Tue, Nov 20, 2018 at 02:43:23PM +0100, Michal Hocko wrote: > > From: Michal Hocko <mhocko@xxxxxxxx> > > > > 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. > > Looks fine to me. Thanks for the review. > But please drop a line of comment in the code. As is it might be confusing > for a reader. This? diff --git a/mm/filemap.c b/mm/filemap.c index c76d6a251770..7c4e439a2e85 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2554,6 +2554,10 @@ void filemap_map_pages(struct vm_fault *vmf, head = compound_head(page); + /* + * Check the locked pages before taking a reference to not + * go in the way of migration. + */ if (PageLocked(head)) goto next; if (!page_cache_get_speculative(head)) -- Michal Hocko SUSE Labs