Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1180338

[PATCH v2 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch

From Mike Kravetz <mike.kravetz@oracle.com>
Newsgroups linux.kernel
Subject [PATCH v2 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch
Date 2015-07-09 02:30 +0200
Message-ID <pK7SX-1AK-31@gated-at.bofh.it> (permalink)
References <pK7SW-1AK-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <mike.kravetz@oracle.com>
---
 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 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/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/10] hugetlbfs: add fallocate support Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
  [PATCH v2 05/10] hugetlbfs: truncate_hugepages() takes a range of pages Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
  [PATCH v2 07/10] mm/hugetlb: alloc_huge_page handle areas hole punched by fallocate Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
  [PATCH v2 03/10] mm/hugetlb: expose hugetlb fault mutex for use by fallocate Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
  [PATCH v2 09/10] hugetlbfs: add hugetlbfs_fallocate() Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
  [PATCH v2 01/10] mm/hugetlb: add cache of descriptors to resv_map for region_add Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200
    Re: [PATCH v2 01/10] mm/hugetlb: add cache of descriptors to resv_map  for region_add Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:50 +0200
  [PATCH v2 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch Mike Kravetz <mike.kravetz@oracle.com> - 2015-07-09 02:30 +0200

csiph-web