From: Mike Kravetz Date: Tue, 8 Sep 2015 22:01:44 +0000 (-0700) Subject: mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1fb1b0e9ef2d661488f8053986c3b7641cae529d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch In vma_has_reserves(), the current assumption is that reserves are always present for shared mappings. However, this will not be the case with fallocate hole punch. When punching a hole, the present page will be deleted as well as the region/reserve map entry (and hence any reservation). vma_has_reserves is passed "chg" which indicates whether or not a region/reserve map is present. Use this to determine if reserves are actually present or were removed via hole punch. Signed-off-by: Mike Kravetz Reviewed-by: Naoya Horiguchi Acked-by: Hillf Danton Cc: Dave Hansen Cc: David Rientjes Cc: Hugh Dickins Cc: Davidlohr Bueso Cc: Aneesh Kumar Cc: Christoph Hellwig Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 61c52cd5f77b..bd12e8c8bc7b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -801,8 +801,19 @@ static bool vma_has_reserves(struct vm_area_struct *vma, long chg) } /* Shared mappings always use reserves */ - if (vma->vm_flags & VM_MAYSHARE) - return true; + if (vma->vm_flags & VM_MAYSHARE) { + /* + * We know VM_NORESERVE is not set. Therefore, there SHOULD + * be a region map for all pages. The only situation where + * there is no region map is if a hole was punched via + * fallocate. In this case, there really are no reverves to + * use. This situation is indicated if chg != 0. + */ + if (chg) + return false; + else + return true; + } /* * Only the process that called mmap() has reserves for