Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751925AbdFIOWK (ORCPT ); Fri, 9 Jun 2017 10:22:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58770 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751884AbdFIOWI (ORCPT ); Fri, 9 Jun 2017 10:22:08 -0400 From: Laurent Dufour To: 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 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 Subject: [RFC v4 19/20] powerpc/mm: Add speculative page fault Date: Fri, 9 Jun 2017 16:21:08 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497018069-17790-1-git-send-email-ldufour@linux.vnet.ibm.com> References: <1497018069-17790-1-git-send-email-ldufour@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060914-0040-0000-0000-000003C652EB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060914-0041-0000-0000-0000205E6D57 Message-Id: <1497018069-17790-20-git-send-email-ldufour@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-09_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706090251 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1796 Lines: 60 This patch enable the speculative page fault on the PowerPC architecture. This will try a speculative page fault without holding the mmap_sem, if it returns with WM_FAULT_RETRY, the mmap_sem is acquired and the traditional page fault processing is done. Signed-off-by: Laurent Dufour --- arch/powerpc/mm/fault.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 3a7d580fdc59..6dd6a50f412f 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -290,9 +290,32 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, if (!is_exec && user_mode(regs)) store_update_sp = store_updates_sp(regs); - if (user_mode(regs)) + if (user_mode(regs)) { flags |= FAULT_FLAG_USER; + /* let's try a speculative page fault without grabbing the + * mmap_sem. + */ + + /* + * flags is set later based on the VMA's flags, for the common + * speculative service, we need some flags to be set. + */ + if (is_write) + flags |= FAULT_FLAG_WRITE; + + fault = handle_speculative_fault(mm, address, + flags & ~FAULT_FLAG_ALLOW_RETRY); + if (!(fault & VM_FAULT_RETRY || fault & VM_FAULT_ERROR)) + goto done; + + /* + * Resetting flags since the following code assumes + * FAULT_FLAG_WRITE is not set. + */ + flags &= ~FAULT_FLAG_WRITE; + } + /* When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in the * kernel and should generate an OOPS. Unfortunately, in the case of an @@ -478,6 +501,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, rc = 0; } +done: /* * Major/minor page fault accounting. */ -- 2.7.4