mm: hugetlb: fix pgoff computation when unmapping page from vma
authorHillf Danton <[email protected]>
Tue, 10 Jan 2012 23:08:19 +0000 (15:08 -0800)
committerLinus Torvalds <[email protected]>
Wed, 11 Jan 2012 00:30:45 +0000 (16:30 -0800)
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.

[[email protected]: use vma_hugecache_offset() directly, per Michal]
Signed-off-by: Hillf Danton <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: David Rientjes <[email protected]>
Reviewed-by: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/hugetlb.c

index ab89d6f382d1274a8294f8fd385f82d864400674..bb7dc405634ff38bb25a4765618a9e295d3069d7 100644 (file)
@@ -2315,8 +2315,7 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
         * from page cache lookup which is in HPAGE_SIZE units.
         */
        address = address & huge_page_mask(h);
-       pgoff = ((address - vma->vm_start) >> PAGE_SHIFT)
-               + (vma->vm_pgoff >> PAGE_SHIFT);
+       pgoff = vma_hugecache_offset(h, vma, address);
        mapping = (struct address_space *)page_private(page);
 
        /*