From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754264AbdJLBrE (ORCPT ); Wed, 11 Oct 2017 21:47:04 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:31543 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbdJLBq5 (ORCPT ); Wed, 11 Oct 2017 21:46:57 -0400 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Marek Szyprowski , Michal Nazarewicz , "Aneesh Kumar K . V" , Joonsoo Kim , Guy Shattah , Christoph Lameter , Anshuman Khandual , Laura Abbott , Vlastimil Babka , Mike Kravetz Subject: [RFC PATCH 2/3] mm/map_contig: Use pre-allocated pages for VM_CONTIG mappings Date: Wed, 11 Oct 2017 18:46:10 -0700 Message-Id: <20171012014611.18725-3-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171012014611.18725-1-mike.kravetz@oracle.com> References: <21f1ec96-2822-1189-1c95-79a2bb491571@oracle.com> <20171012014611.18725-1-mike.kravetz@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When populating mappings backed by contiguous memory allocations (VM_CONTIG), use the preallocated pages instead of allocating new. Signed-off-by: Mike Kravetz --- 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