Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933688AbbGUSLf (ORCPT ); Tue, 21 Jul 2015 14:11:35 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:28811 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933669AbbGUSLc (ORCPT ); Tue, 21 Jul 2015 14:11:32 -0400 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Dave Hansen , Naoya Horiguchi , David Rientjes , Hugh Dickins , Davidlohr Bueso , Aneesh Kumar , Hillf Danton , Christoph Hellwig , Andrew Morton , Michal Hocko , Mike Kravetz Subject: [PATCH v4 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch Date: Tue, 21 Jul 2015 11:09:40 -0700 Message-Id: <1437502184-14269-7-git-send-email-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1437502184-14269-1-git-send-email-mike.kravetz@oracle.com> References: <1437502184-14269-1-git-send-email-mike.kravetz@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1652 Lines: 48 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 --- mm/hugetlb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index db9caea..f9d3faf 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -803,8 +803,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 -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/