mm/vma: append unlikely() while testing VMA access permissions
authorAnshuman Khandual <anshuman.khandual@arm.com>
Tue, 7 Apr 2020 03:03:59 +0000 (20:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Apr 2020 17:43:38 +0000 (10:43 -0700)
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: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew 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.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/csky/mm/fault.c
arch/m68k/mm/fault.c
arch/mips/mm/fault.c

index a6e8230b6fbfa7a48c581472ce65c9ba082eae00..4e6dc68f325848d093cc5866a84b809f0a3d4a2d 100644 (file)
@@ -141,7 +141,7 @@ good_area:
                if (!(vma->vm_flags & VM_WRITE))
                        goto bad_area;
        } else {
-               if (!vma_is_accessible(vma))
+               if (unlikely(!vma_is_accessible(vma)))
                        goto bad_area;
        }
 
index 0c4a21a685d590b4db6a7401e5a3790b12aad8e7..3bfb5c8ac3c7a67d3da2cfda79affb4df0f2ce5b 100644 (file)
@@ -125,7 +125,7 @@ good_area:
                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;
        }
 
index fb048ba2b91d4af7c2d25c60de4752b0fa0f18dc..f8d62cd83b36ce3d3729388789af30937dfb5c3c 100644 (file)
@@ -142,7 +142,7 @@ good_area:
                                goto bad_area;
                        }
                } else {
-                       if (!vma_is_accessible(vma))
+                       if (unlikely(!vma_is_accessible(vma)))
                                goto bad_area;
                }
        }