Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: hugetlb: fix pgoff computation when unmapping page from vma

The computation for pgoff is incorrect, at least with

(vma->vm_pgoff >> PAGE_SHIFT)

involved. It is fixed with the available method if HPAGE_SIZE is
concerned in page cache lookup.

[akpm@linux-foundation.org: use vma_hugecache_offset() directly, per Michal]
Signed-off-by: Hillf Danton <dhillf@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michal Hocko <mhocko@suse.cz>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hillf Danton and committed by
Linus Torvalds
0c176d52 86cfd3a4

+1 -2
+1 -2
mm/hugetlb.c
··· 2315 2315 * from page cache lookup which is in HPAGE_SIZE units. 2316 2316 */ 2317 2317 address = address & huge_page_mask(h); 2318 - pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) 2319 - + (vma->vm_pgoff >> PAGE_SHIFT); 2318 + pgoff = vma_hugecache_offset(h, vma, address); 2320 2319 mapping = (struct address_space *)page_private(page); 2321 2320 2322 2321 /*