lkml.org 
[lkml]   [2015]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v3 PATCH 08/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch
Date
In vma_has_reserves(), the current assumption is that reserves are
always present for shared mappings. However, 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 449cf5f..94c6154 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -559,9 +559,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


\
 
 \ /
  Last update: 2015-05-21 18:41    [W:0.885 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site