From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xbQN03cl5zDrJK for ; Mon, 21 Aug 2017 17:30:56 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7L7Sx4a023024 for ; Mon, 21 Aug 2017 03:30:54 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cfsnkv60p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 21 Aug 2017 03:30:53 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Aug 2017 17:30:51 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7L7TZf536962382 for ; Mon, 21 Aug 2017 17:29:35 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v7L7TX26020832 for ; Mon, 21 Aug 2017 17:29:35 +1000 Subject: Re: [PATCH v2 19/20] x86/mm: Add speculative pagefault handling To: Laurent Dufour , paulmck@linux.vnet.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon References: <1503007519-26777-1-git-send-email-ldufour@linux.vnet.ibm.com> <1503007519-26777-20-git-send-email-ldufour@linux.vnet.ibm.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org From: Anshuman Khandual Date: Mon, 21 Aug 2017 12:59:24 +0530 MIME-Version: 1.0 In-Reply-To: <1503007519-26777-20-git-send-email-ldufour@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Message-Id: List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 08/18/2017 03:35 AM, Laurent Dufour wrote: > From: Peter Zijlstra > > Try a speculative fault before acquiring mmap_sem, if it returns with > VM_FAULT_RETRY continue with the mmap_sem acquisition and do the > traditional fault. > > Signed-off-by: Peter Zijlstra (Intel) > > [Clearing of FAULT_FLAG_ALLOW_RETRY is now done in > handle_speculative_fault()] > [Retry with usual fault path in the case VM_ERROR is returned by > handle_speculative_fault(). This allows signal to be delivered] > Signed-off-by: Laurent Dufour > --- > arch/x86/include/asm/pgtable_types.h | 7 +++++++ > arch/x86/mm/fault.c | 19 +++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h > index bf9638e1ee42..4fd2693a037e 100644 > --- a/arch/x86/include/asm/pgtable_types.h > +++ b/arch/x86/include/asm/pgtable_types.h > @@ -234,6 +234,13 @@ enum page_cache_mode { > #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */ > #endif > > +/* > + * Advertise that we call the Speculative Page Fault handler. > + */ > +#ifdef CONFIG_X86_64 > +#define __HAVE_ARCH_CALL_SPF > +#endif > + > #ifdef CONFIG_X86_32 > # include > #else > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index 2a1fa10c6a98..4c070b9a4362 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -1365,6 +1365,24 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > if (error_code & PF_INSTR) > flags |= FAULT_FLAG_INSTRUCTION; > > +#ifdef __HAVE_ARCH_CALL_SPF > + if (error_code & PF_USER) { > + fault = handle_speculative_fault(mm, address, flags); > + > + /* > + * We also check against VM_FAULT_ERROR because we have to > + * raise a signal by calling later mm_fault_error() which > + * requires the vma pointer to be set. So in that case, > + * we fall through the normal path. Cant mm_fault_error() be called inside handle_speculative_fault() ? Falling through the normal page fault path again just to raise a signal seems overkill. Looking into mm_fault_error(), it seems they are different for x86 and powerpc. X86: mm_fault_error(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct vm_area_struct *vma, unsigned int fault) powerpc: mm_fault_error(struct pt_regs *regs, unsigned long addr, int fault) Even in case of X86, I guess we would have reference to the faulting VMA (after the SRCU search) which can be used to call this function directly.