Received: by 10.192.165.148 with SMTP id m20csp399060imm; Wed, 2 May 2018 02:10:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZraxtcQUpZR8zJoQI7M7kljBJhskq3paCp0B10aNQ+r4TFPgnbqLzF/xuqyWatfSgdjxWiv X-Received: by 2002:a63:9e12:: with SMTP id s18-v6mr4929123pgd.207.1525252233661; Wed, 02 May 2018 02:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525252233; cv=none; d=google.com; s=arc-20160816; b=cs65f9iiSMyllxRUgOrn5+DSt6AZsX1qX/aVaBezmQb/c30hRW6Dmqa35IMqFX1UKT 6O96hJjh0GB3abU9Vud74gCzHC5Et1+j9QjQLRpX5BurtIZvK4c4ehXKZZ4ijj3vvTBr zcVmP/nswCiBhY6oR6300ptC7pksv8Z0nrcoQhSszEaoOEb7FcOdg50ujSl/DlhRAJba 5FFTbuYdTlWqlA+5tZKoz6xUUWcIaTF+tKJiefE2Q0kLi6kLYFkJ39hNK82pVwAt5xjH OOYVSrznGF9UmKpF8gCOcdPCwcVELh2e7BUtjpCr5aBHvOWNwMI53z21YT/j69U8l63Y KkzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=e+irlvThkr/wUbNSTueO8hqtS3sgWIDimJ/LrJYGOfA=; b=Ja5Jb3x5tJX/PYNwn+o7Jrf75mscHb0UEfZp8XvOkkySeaee+QUOaMIbu1m4KuW0AT 9WtHLe//1BgQhDV/zjJb2A+77O6rVrsj1Sm+iQDV0lRDIb52uU0/sSDWIQJ5EBaqAvYR PDigJuYvIAj8x0vIdWYeglC/V0gAu+T80rMrOGM+R1QYqh3Xrir/Uqm4NyQcfh87q1Vi NSe7z5VQoaH25WnoAS29rBLRtqgCRFhpPyQGB7R/74NxgyLLYH3cDrL3Q+CDKN01l9op LvKk5WU9Ua8uV9Jy+fyztJ83kJapJxvTtujOWiKCHV3gcxwLuUFezNZSpIqAKq9BNOFL 7Hiw== 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 v40-v6si11269190plg.84.2018.05.02.02.10.19; Wed, 02 May 2018 02:10:33 -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 S1751079AbeEBJIY (ORCPT + 99 others); Wed, 2 May 2018 05:08:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53570 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbeEBJHQ (ORCPT ); Wed, 2 May 2018 05:07:16 -0400 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 w4292P1w143489 for ; Wed, 2 May 2018 05:07:15 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hq8wskw0e-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 02 May 2018 05:07:15 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 May 2018 10:07:12 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 May 2018 10:07:10 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w42979JK5767486; Wed, 2 May 2018 09:07:09 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA8C042042; Wed, 2 May 2018 09:58:21 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5484D4203F; Wed, 2 May 2018 09:58:21 +0100 (BST) Received: from [9.145.16.142] (unknown [9.145.16.142]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 2 May 2018 09:58:21 +0100 (BST) Subject: Re: [PATCH 2/2] arm64/mm: add speculative page fault To: Ganesh Mahendran , catalin.marinas@arm.com, will.deacon@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Punit Agrawal References: <1525247672-2165-1-git-send-email-opensource.ganesh@gmail.com> <1525247672-2165-2-git-send-email-opensource.ganesh@gmail.com> From: Laurent Dufour Date: Wed, 2 May 2018 11:07:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1525247672-2165-2-git-send-email-opensource.ganesh@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18050209-0012-0000-0000-000005D10CB8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050209-0013-0000-0000-0000194E2C2F Message-Id: <9e7ab02c-a9af-71ed-afda-108e3b26b2ef@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-02_03:,, 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-1805020074 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/05/2018 09:54, Ganesh Mahendran wrote: > This patch enables the speculative page fault on the arm64 > architecture. > > I completed spf porting in 4.9. From the test result, > we can see app launching time improved by about 10% in average. > For the apps which have more than 50 threads, 15% or even more > improvement can be got. Thanks Ganesh, That's a great improvement, could you please provide details about the apps and the hardware you used ? > > Signed-off-by: Ganesh Mahendran > --- > This patch is on top of Laurent's v10 spf > --- > arch/arm64/mm/fault.c | 38 +++++++++++++++++++++++++++++++++++--- > 1 file changed, 35 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index 4165485..e7992a3 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -322,11 +322,13 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re > > static int __do_page_fault(struct mm_struct *mm, unsigned long addr, > unsigned int mm_flags, unsigned long vm_flags, > - struct task_struct *tsk) > + struct task_struct *tsk, struct vm_area_struct *vma) > { > - struct vm_area_struct *vma; > int fault; > > + if (!vma || !can_reuse_spf_vma(vma, addr)) > + vma = find_vma(mm, addr); > + > vma = find_vma(mm, addr); > fault = VM_FAULT_BADMAP; > if (unlikely(!vma)) > @@ -371,6 +373,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, > int fault, major = 0; > unsigned long vm_flags = VM_READ | VM_WRITE; > unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; > + struct vm_area_struct *vma; > > if (notify_page_fault(regs, esr)) > return 0; > @@ -409,6 +412,25 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, > > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); > > + if (IS_ENABLED(CONFIG_SPECULATIVE_PAGE_FAULT)) { As suggested by Punit in his v10's review, the test on CONFIG_SPECULATIVE_PAGE_FAULT is not needed as handle_speculative_fault() is defined to return VM_FAULT_RETRY is the config is not set. > + fault = handle_speculative_fault(mm, addr, mm_flags, &vma); > + /* > + * 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. > + */ The check of VM_FAULT_SIGSEGV was needed on ppc64 because of the memory protection key support, but as far as I know, this is not the case on arm64. Isn't it ? > + if (fault != VM_FAULT_RETRY && > + fault != VM_FAULT_SIGSEGV) { > + perf_sw_event(PERF_COUNT_SW_SPF, 1, regs, addr); > + goto done; > + } > + } else { > + vma = NULL; > + } > + > /* > * As per x86, we may deadlock here. However, since the kernel only > * validly references user space from well defined areas of the code, > @@ -431,7 +453,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, > #endif > } > > - fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk); > + fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk, vma); > major |= fault & VM_FAULT_MAJOR; > > if (fault & VM_FAULT_RETRY) { > @@ -454,11 +476,21 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, > if (mm_flags & FAULT_FLAG_ALLOW_RETRY) { > mm_flags &= ~FAULT_FLAG_ALLOW_RETRY; > mm_flags |= FAULT_FLAG_TRIED; > + > + /* > + * Do not try to reuse this vma and fetch it > + * again since we will release the mmap_sem. > + */ > + if (IS_ENABLED(CONFIG_SPECULATIVE_PAGE_FAULT)) > + vma = NULL; > + > goto retry; > } > } > up_read(&mm->mmap_sem); > > +done: > + > /* > * Handle the "normal" (no error) case first. > */ >