From patchwork Mon Feb 24 06:21:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 11399379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B41C1580 for ; Mon, 24 Feb 2020 06:22:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5FC92072D for ; Mon, 24 Feb 2020 06:22:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5FC92072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1852D6B0005; Mon, 24 Feb 2020 01:22:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 10CFF6B0006; Mon, 24 Feb 2020 01:22:01 -0500 (EST) 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 048AC6B0007; Mon, 24 Feb 2020 01:22:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id DE4376B0005 for ; Mon, 24 Feb 2020 01:22:00 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7DE0E181AC9BF for ; Mon, 24 Feb 2020 06:22:00 +0000 (UTC) X-FDA: 76524025200.12.baby10_2e8f2309d2041 X-Spam-Summary: 2,0,0,a5537ddb5444cc8c,d41d8cd98f00b204,anshuman.khandual@arm.com,,RULES_HIT:41:355:379:541:800:960:967:973:988:989:1260:1261:1345:1431:1437:1534:1542:1711:1730:1747:1777:1792:1963:2198:2199:2393:2525:2559:2563:2682:2685:2693:2731:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:6261:6742:8634:9025:10004:11026:11232:11658:11914:12043:12296:12297:12555:12895:12986:13141:13230:14096:14181:14394:14721:21063:21080:21451:21627:21740:30003:30054:30056,0,RBL:217.140.110.172:@arm.com:.lbl8.mailshell.net-64.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: baby10_2e8f2309d2041 X-Filterd-Recvd-Size: 3585 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 06:21:59 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED65D30E; Sun, 23 Feb 2020 22:21:58 -0800 (PST) Received: from p8cg001049571a15.blr.arm.com (p8cg001049571a15.blr.arm.com [10.162.16.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B2B4E3F534; Sun, 23 Feb 2020 22:25:45 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Guo Ren , Geert Uytterhoeven , Ralf Baechle , Paul Burton , Mike Rapoport , Andrew Morton , linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/vma: Append unlikely() while testing VMA access permissions Date: Mon, 24 Feb 2020 11:51:44 +0530 Message-Id: <1582525304-32113-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 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: It is unlikely that an inaccessible VMA without required permission flags will get a page fault. Hence lets just append unlikely() directive to such checks in order to improve performance while also standardizing it across various platforms. Cc: Guo Ren Cc: Geert Uytterhoeven Cc: Ralf Baechle Cc: Paul Burton Cc: Mike Rapoport Cc: Andrew Morton Cc: linux-m68k@lists.linux-m68k.org Cc: linux-mips@vger.kernel.org Cc: linux-csky@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This patch applies on v5.6-rc3 along with the recent VMA series V2 (https://patchwork.kernel.org/cover/11399319/). This has only been build tested for mips and m68k platforms. arch/csky/mm/fault.c | 2 +- arch/m68k/mm/fault.c | 2 +- arch/mips/mm/fault.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c index 4b3511b8298d..01caae98c350 100644 --- a/arch/csky/mm/fault.c +++ b/arch/csky/mm/fault.c @@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, if (!(vma->vm_flags & VM_WRITE)) goto bad_area; } else { - if (!vma_is_accessible(vma)) + if (unlikely(!vma_is_accessible(vma))) goto bad_area; } diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index d5131ec5d923..d5dd75ed77f1 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c @@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, case 1: /* read, present */ goto acc_err; case 0: /* read, not present */ - if (!vma_is_accessible(vma)) + if (unlikely(!vma_is_accessible(vma))) goto acc_err; } diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 5b9f947bfa32..db4b51a40c58 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, goto bad_area; } } else { - if (!vma_is_accessible(vma)) + if (unlikely(!vma_is_accessible(vma))) goto bad_area; } }