From patchwork Thu May 17 11:06:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 10406435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A73D9602C2 for ; Thu, 17 May 2018 11:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 968252886D for ; Thu, 17 May 2018 11:08:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A9B128899; Thu, 17 May 2018 11:08:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 262082886D for ; Thu, 17 May 2018 11:08:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B7186B04C8; Thu, 17 May 2018 07:07:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 53C956B04C9; Thu, 17 May 2018 07:07:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 392906B04CA; Thu, 17 May 2018 07:07:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by kanga.kvack.org (Postfix) with ESMTP id F3ACA6B04C8 for ; Thu, 17 May 2018 07:07:47 -0400 (EDT) Received: by mail-qk0-f197.google.com with SMTP id p190-v6so3551514qkc.17 for ; Thu, 17 May 2018 04:07:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=tDX1ThUrmG7+mURUxO4HL8e0eQsJvLd9nezQSL06BjE=; b=Pyi3f2iun/YN8nX7fdkDHzzyJmqydxEWLzAdSfJPvkQqsLZP4KWWee0Rggof0mMMu9 UB5rgCtEX100p+xCsN/X1yEO2rCvw6r58MT0tQcvmKomXfNggEB3uY1XnHXkR+gP4k/b e7FogzJfX2ds5f0MKJGo6mzVeO+ut5qnO0GMymYztyk7cAnOYy9A2xvqHSOEP8Xm+s8a NYMumgGg61sh8hrPCNCURsnptepTlZUWf0mujXJaeLpCSH45CQvZsK9mItWtyfk4082c Xr+MyFMjlywAWlSDPf7sfN5mvT+rF+xe5QE5GTJbyyhHE6pZHO3cd2bHO5kzJuD27k1J MA8A== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of ldufour@linux.vnet.ibm.com) smtp.mailfrom=ldufour@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: ALKqPwc/cDjzAsosMaPqzle+BMNGW/42XoW3icQLNzFr9ePMaTFrIaOz MAPYhWhh+KWXAKaD0YUoGIZVbHOHkNSx75CXl2v11J+bfVM/3v7X1+nMHiW4tlxFvVE4T+7zmk1 G1ZU3jb2GqlK2FxuG6ixb4QGsFAGtoLQHj0OH5Lcv5110aqxzShpnpuKDYGp+wOQ= X-Received: by 2002:a37:6749:: with SMTP id b70-v6mr4498629qkc.94.1526555267762; Thu, 17 May 2018 04:07:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo/8EJdYzm5/kJMLZvf9GpFfzjrSK+o1nrVWc+BTbEZ59bk3NZjTbjXj6DiHBv9TNV7Aiyn X-Received: by 2002:a37:6749:: with SMTP id b70-v6mr4498594qkc.94.1526555267222; Thu, 17 May 2018 04:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526555267; cv=none; d=google.com; s=arc-20160816; b=Tp/vwqMt3E8LW8/eRlerXz7fytUMH4E5JSfXKY+6pweDsVeBAf7SbkM0jLnXSGsFg1 tUHUztJVLZp3z6vpuYFxOkjGJXWMdiz4ZYXRMMsk6BUg3MVUwf1DT9kod5SN7VR3qxPL 0t38aKkLTZ6Qxhww6ycYwYHBu+fD8l9K/kzkrJaOqVR98ya+KnUCcEy9w5RPvhKFMrvc bXRBmnKjAV/jw+yNYk+yDMCJRs4QkhtIGyk6Fm9DvnXZdyjeeZ9fjgnniJ/SyLoeBzBr J17TsZdOvDjm5XU5Hbh98zMAvmTs+MwfevjWS/q+vIfjOwy4tow1KIj/J71ryrvvynTH 8fEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=tDX1ThUrmG7+mURUxO4HL8e0eQsJvLd9nezQSL06BjE=; b=lFUF3iSoHPenHiJ5CV49fmBQncJuDTabjq4MAy/H8slDu4F9PbuLOjJeE4jjnq9LvP z4bU2Ji8AD2n1nOYDwReycdnSUuanIekUUAHBvmqInaaw73mH8Gz+ZfxXtG1dboIAzVX VauslKHaIjuF3J+Onqew/GWAmSC6/hl/P6gdZJNN5IRqYl6UfXRsLqDUReONGYGlKCLY /kP1+W9HlBnJ4v/y7j7Xn82wHM/kOqvhOwXmXKuXmWH/1nNAFZ4xwySws6FrwZpEU8m4 jLLZ+nwCpYcoon2uYTYf7LVS9pdxavGP2XX0iJ92dwszqYi2mLoOhZAPjf42IsnPxkwE esTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of ldufour@linux.vnet.ibm.com) smtp.mailfrom=ldufour@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id r126-v6si360546qke.293.2018.05.17.04.07.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 04:07:47 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of ldufour@linux.vnet.ibm.com) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of ldufour@linux.vnet.ibm.com) smtp.mailfrom=ldufour@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4HB4BAE022824 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 2j187ph2tj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 May 2018 07:07:46 -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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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);