提交 7f09ca51 编写于 作者: M Mel Gorman 提交者: Linus Torvalds

hugetlb: fix a hugepage reservation check for MAP_SHARED

When removing a huge page from the hugepage pool for a fault the system checks
to see if the mapping requires additional pages to be reserved, and if it does
whether there are any unreserved pages remaining.  If not, the allocation
fails without even attempting to get a page.  In order to determine whether to
apply this check we call vma_has_private_reserves() which tells us if this vma
is MAP_PRIVATE and is the owner.  This incorrectly triggers the remaining
reservation test for MAP_SHARED mappings which prevents allocation of the
final page in the pool even though it is reserved for this mapping.

In reality we only want to check this for MAP_PRIVATE mappings where the
process is not the original mapper.  Replace vma_has_private_reserves() with
vma_has_reserves() which indicates whether further reserves are required, and
update the caller.
Signed-off-by: NMel Gorman <mel@csn.ul.ie>
Acked-by: NAdam Litke <agl@us.ibm.com>
Acked-by: NAndy Whitcroft <apw@shadowen.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0d9ea754
...@@ -342,13 +342,13 @@ void reset_vma_resv_huge_pages(struct vm_area_struct *vma) ...@@ -342,13 +342,13 @@ void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
} }
/* Returns true if the VMA has associated reserve pages */ /* Returns true if the VMA has associated reserve pages */
static int vma_has_private_reserves(struct vm_area_struct *vma) static int vma_has_reserves(struct vm_area_struct *vma)
{ {
if (vma->vm_flags & VM_SHARED) if (vma->vm_flags & VM_SHARED)
return 0;
if (!is_vma_resv_set(vma, HPAGE_RESV_OWNER))
return 0;
return 1; return 1;
if (is_vma_resv_set(vma, HPAGE_RESV_OWNER))
return 1;
return 0;
} }
static void clear_huge_page(struct page *page, static void clear_huge_page(struct page *page,
...@@ -420,7 +420,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h, ...@@ -420,7 +420,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
* have no page reserves. This check ensures that reservations are * have no page reserves. This check ensures that reservations are
* not "stolen". The child may still get SIGKILLed * not "stolen". The child may still get SIGKILLed
*/ */
if (!vma_has_private_reserves(vma) && if (!vma_has_reserves(vma) &&
h->free_huge_pages - h->resv_huge_pages == 0) h->free_huge_pages - h->resv_huge_pages == 0)
return NULL; return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册