lkml.org 
[lkml]   [2017]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 2/3] mm/map_contig: Use pre-allocated pages for VM_CONTIG mappings
Date
When populating mappings backed by contiguous memory allocations
(VM_CONTIG), use the preallocated pages instead of allocating new.

Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
mm/memory.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index a728bed16c20..fbef78d07cf3 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3100,7 +3100,18 @@ static int do_anonymous_page(struct vm_fault *vmf)
/* Allocate our own private page. */
if (unlikely(anon_vma_prepare(vma)))
goto oom;
- page = alloc_zeroed_user_highpage_movable(vma, vmf->address);
+
+ /*
+ * In the special VM_CONTIG case, pages have been pre-allocated. So,
+ * simply grab the appropriate pre-allocated page.
+ */
+ if (unlikely(vma->vm_flags & VM_CONTIG)) {
+ VM_BUG_ON(!vma->vm_private_data);
+ page = ((struct page *)vma->vm_private_data) +
+ ((vmf->address - vma->vm_start) / PAGE_SIZE);
+ } else {
+ page = alloc_zeroed_user_highpage_movable(vma, vmf->address);
+ }
if (!page)
goto oom;

--
2.13.6
\
 
 \ /
  Last update: 2017-10-12 03:50    [W:2.183 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site