[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1582525304-32113-1-git-send-email-anshuman.khandual@arm.com>
Date: Mon, 24 Feb 2020 11:51:44 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: linux-mm@...ck.org
Cc: Anshuman Khandual <anshuman.khandual@....com>,
Guo Ren <guoren@...nel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Paul Burton <paulburton@...nel.org>,
Mike Rapoport <rppt@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-m68k@...ts.linux-m68k.org, linux-mips@...r.kernel.org,
linux-csky@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] mm/vma: Append unlikely() while testing VMA access permissions
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 <guoren@...nel.org>
Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Ralf Baechle <ralf@...ux-mips.org>
Cc: Paul Burton <paulburton@...nel.org>
Cc: Mike Rapoport <rppt@...ux.ibm.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-m68k@...ts.linux-m68k.org
Cc: linux-mips@...r.kernel.org
Cc: linux-csky@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
---
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;
}
}
--
2.20.1
Powered by blists - more mailing lists