Commit 5093c587 authored by Anshuman Khandual's avatar Anshuman Khandual Committed by Linus Torvalds

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.
Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Link: http://lkml.kernel.org/r/1582525304-32113-1-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a0137f16
...@@ -141,7 +141,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, ...@@ -141,7 +141,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
if (!(vma->vm_flags & VM_WRITE)) if (!(vma->vm_flags & VM_WRITE))
goto bad_area; goto bad_area;
} else { } else {
if (!vma_is_accessible(vma)) if (unlikely(!vma_is_accessible(vma)))
goto bad_area; goto bad_area;
} }
......
...@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
case 1: /* read, present */ case 1: /* read, present */
goto acc_err; goto acc_err;
case 0: /* read, not present */ case 0: /* read, not present */
if (!vma_is_accessible(vma)) if (unlikely(!vma_is_accessible(vma)))
goto acc_err; goto acc_err;
} }
......
...@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, ...@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
goto bad_area; goto bad_area;
} }
} else { } else {
if (!vma_is_accessible(vma)) if (unlikely(!vma_is_accessible(vma)))
goto bad_area; goto bad_area;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment