Skip to content

Commit ebed4bf

Browse files
Hugh DickinsLinus Torvalds
authored andcommitted
[PATCH] hugetlb: fix absurd HugePages_Rsvd
If you truncated an mmap'ed hugetlbfs file, then faulted on the truncated area, /proc/meminfo's HugePages_Rsvd wrapped hugely "negative". Reinstate my preliminary i_size check before attempting to allocate the page (though this only fixes the most obvious case: more work will be needed here). Signed-off-by: Hugh Dickins <hugh@veritas.com> Cc: Adam Litke <agl@us.ibm.com> Cc: David Gibson <david@gibson.dropbear.id.au> Cc: "Chen, Kenneth W" <kenneth.w.chen@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 856fc29 commit ebed4bf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/hugetlb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
478478
retry:
479479
page = find_lock_page(mapping, idx);
480480
if (!page) {
481+
size = i_size_read(mapping->host) >> HPAGE_SHIFT;
482+
if (idx >= size)
483+
goto out;
481484
if (hugetlb_get_quota(mapping))
482485
goto out;
483486
page = alloc_huge_page(vma, address);

0 commit comments

Comments
 (0)