Skip to content

Commit f037cf0

Browse files
Michal Hockogregkh
Michal Hocko
authored andcommitted
hugetlb: do not use vma_hugecache_offset() for vma_prio_tree_foreach
commit 36e4f20 upstream. Commit 0c176d5 ("mm: hugetlb: fix pgoff computation when unmapping page from vma") fixed pgoff calculation but it has replaced it by vma_hugecache_offset() which is not approapriate for offsets used for vma_prio_tree_foreach() because that one expects index in page units rather than in huge_page_shift. Johannes said: : The resulting index may not be too big, but it can be too small: assume : hpage size of 2M and the address to unmap to be 0x200000. This is regular : page index 512 and hpage index 1. If you have a VMA that maps the file : only starting at the second huge page, that VMAs vm_pgoff will be 512 but : you ask for offset 1 and miss it even though it does map the page of : interest. hugetlb_cow() will try to unmap, miss the vma, and retry the : cow until the allocation succeeds or the skipped vma(s) go away. Signed-off-by: Michal Hocko <mhocko@suse.cz> Acked-by: Hillf Danton <dhillf@gmail.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: David Rientjes <rientjes@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ac8d332 commit f037cf0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/hugetlb.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,8 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
24812481
* from page cache lookup which is in HPAGE_SIZE units.
24822482
*/
24832483
address = address & huge_page_mask(h);
2484-
pgoff = vma_hugecache_offset(h, vma, address);
2484+
pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) +
2485+
vma->vm_pgoff;
24852486
mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
24862487

24872488
/*

0 commit comments

Comments
 (0)