Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3137750imm; Thu, 17 May 2018 04:08:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqFXTzTOPiWI+OAv4mnkz34sC57HqOApQ/yEgLeEn/JBQGjR86NoBF13EilhBUjEf3OriTU X-Received: by 2002:a62:9515:: with SMTP id p21-v6mr4784834pfd.62.1526555309531; Thu, 17 May 2018 04:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526555309; cv=none; d=google.com; s=arc-20160816; b=XFj74i4nw0A9Fj3+ALCcO2IZuUAtss9sMGrvf6FW1+0VKtJrV8zzDaitZ0q9ay8+J6 omF77NfBemxFJ4d6WVn+4AJ1nc6MSoXz8nJM3gl+HqzWO3HVDSrGl+uaETr+pwWnx4Y9 k0efH2j/OTsOPkrHJwWoHUeOSxnqtBUWVWSNphH1Y/9duAP06Rno4zRHdV+eSSk5kXzG PyAROwX5w0fDA/WO9p65c9zV7CGdVSgvGx2Fu+VNnMe0ex8WeEwXDEYF+3lOu0jfjX8j e50krBMkpjg5kbMhYeJ1l8dWA2K8KKNNBgD34GlLT3zwJTizf8V3CPxV8M/NmQb1yIvG OPgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=tDX1ThUrmG7+mURUxO4HL8e0eQsJvLd9nezQSL06BjE=; b=AtWgkF9cGspCBczljSoBptD4WgELPpPbbsRcKkUsBRoMQA9x3Jggrc9Gbmdhnl1UHq xZqO1SrRgzx31FfKJijSdzJ0ai7XBtOVDn2w7DsPAOO8GAmR+vfHecHwDA0ALVEfWYdV TxcfRHntRAbiWs+ph3zqFuAgjKuOr2xMnRqT43PD6A8WJ0/xxkS8yZptvlpkxBu9CTDT NOXZjkPOtrKPkXGnnaWEJm2UjsUak3+7LqiGVcch4mVv2XKiyVEgho1UYnhk63bTRCDQ C3+DuccxEST4AbuZiAsmyVcSGuT+uhJOVs/nxqHk4sepCnW+OTlIqQd0C/n+TJttM3Lx nDUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si4948809plo.363.2018.05.17.04.08.15; Thu, 17 May 2018 04:08:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428AbeEQLHv (ORCPT + 99 others); Thu, 17 May 2018 07:07:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53264 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbeEQLHq (ORCPT ); Thu, 17 May 2018 07:07:46 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4HB4jj9043138 for ; Thu, 17 May 2018 07:07:46 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j16b5enm2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 May 2018 07:07:45 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 May 2018 12:07:42 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 May 2018 12:07:33 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4HB7XqQ17498476; Thu, 17 May 2018 11:07:33 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16A384C050; Thu, 17 May 2018 11:59:22 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1A454C05A; Thu, 17 May 2018 11:59:20 +0100 (BST) Received: from nimbus.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.33]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 May 2018 11:59:20 +0100 (BST) From: Laurent Dufour To: akpm@linux-foundation.org, mhocko@kernel.org, peterz@infradead.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Jerome Glisse , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH v11 25/26] powerpc/mm: add speculative page fault Date: Thu, 17 May 2018 13:06:32 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526555193-7242-1-git-send-email-ldufour@linux.vnet.ibm.com> References: <1526555193-7242-1-git-send-email-ldufour@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051711-0020-0000-0000-0000041E3570 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051711-0021-0000-0000-000042B35787 Message-Id: <1526555193-7242-26-git-send-email-ldufour@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-17_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805170100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 VM_FAULT_RETRY, the mmap_sem is acquired and the traditional page fault processing is done. The speculative path is only tried for multithreaded process as there is no risk of contention on the mmap_sem otherwise. Signed-off-by: Laurent Dufour --- arch/powerpc/mm/fault.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index ef268d5d9db7..d7b5742ffb2b 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -465,6 +465,21 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, if (is_exec) flags |= FAULT_FLAG_INSTRUCTION; + /* + * Try speculative page fault before grabbing the mmap_sem. + * The Page fault is done if VM_FAULT_RETRY is not returned. + * But if the memory protection keys are active, we don't know if the + * fault is due to key mistmatch or due to a classic protection check. + * To differentiate that, we will need the VMA we no more have, so + * let's retry with the mmap_sem held. + */ + fault = handle_speculative_fault(mm, address, flags); + if (fault != VM_FAULT_RETRY && (IS_ENABLED(CONFIG_PPC_MEM_KEYS) && + fault != VM_FAULT_SIGSEGV)) { + perf_sw_event(PERF_COUNT_SW_SPF, 1, regs, address); + goto done; + } + /* 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 @@ -565,6 +580,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, up_read(¤t->mm->mmap_sem); +done: if (unlikely(fault & VM_FAULT_ERROR)) return mm_fault_error(regs, address, fault); -- 2.7.4