From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yk0-f181.google.com (mail-yk0-f181.google.com [209.85.160.181]) by kanga.kvack.org (Postfix) with ESMTP id CCEAA9003C8 for ; Wed, 8 Jul 2015 20:23:01 -0400 (EDT) Received: by ykee186 with SMTP id e186so22860109yke.2 for ; Wed, 08 Jul 2015 17:23:01 -0700 (PDT) Received: from userp1040.oracle.com (userp1040.oracle.com. [156.151.31.81]) by mx.google.com with ESMTPS id g66si2584751ywd.183.2015.07.08.17.23.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 17:23:00 -0700 (PDT) From: Mike Kravetz Subject: [PATCH v2 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch Date: Wed, 8 Jul 2015 17:21:37 -0700 Message-Id: <1436401301-18839-7-git-send-email-mike.kravetz@oracle.com> In-Reply-To: <1436401301-18839-1-git-send-email-mike.kravetz@oracle.com> References: <1436401301-18839-1-git-send-email-mike.kravetz@oracle.com> Sender: owner-linux-mm@kvack.org List-ID: 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 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d39a6ad..93c7089 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -800,9 +800,19 @@ static int vma_has_reserves(struct vm_area_struct *vma, long chg) return 0; } - /* Shared mappings always use reserves */ - if (vma->vm_flags & VM_MAYSHARE) - return 1; + 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 0; + else + return 1; + } /* * Only the process that called mmap() has reserves for -- 2.1.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org