Skip to content

Commit 1139d33

Browse files
mjkravetztorvalds
authored andcommitted
mm/hugetlb.c: fix pages per hugetlb calculation
The routine hpage_nr_pages() was incorrectly used to calculate the number of base pages in a hugetlb page. hpage_nr_pages is designed to be called for THP pages and will return HPAGE_PMD_NR for hugetlb pages of any size. Due to the context in which hpage_nr_pages was called, it is unlikely to produce a user visible error. The routine with the incorrect call is only exercised in the case of hugetlb memory error or migration. In addition, this would need to be on an architecture which supports huge page sizes less than PMD_SIZE. And, the vma containing the huge page would also need to smaller than PMD_SIZE. Fixes: c0d0381 ("hugetlbfs: use i_mmap_rwsem for more pmd sharing synchronization") Reported-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Mike Kravetz <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Michal Hocko <[email protected]> Cc: "Kirill A . Shutemov" <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent cdd3bb5 commit 1139d33

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/hugetlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ static struct address_space *_get_hugetlb_page_mapping(struct page *hpage)
15931593

15941594
/* Use first found vma */
15951595
pgoff_start = page_to_pgoff(hpage);
1596-
pgoff_end = pgoff_start + hpage_nr_pages(hpage) - 1;
1596+
pgoff_end = pgoff_start + pages_per_huge_page(page_hstate(hpage)) - 1;
15971597
anon_vma_interval_tree_foreach(avc, &anon_vma->rb_root,
15981598
pgoff_start, pgoff_end) {
15991599
struct vm_area_struct *vma = avc->vma;

0 commit comments

Comments
 (0)