x86/uaccess: Add unlikely() to __chk_range_not_ok() failure paths
authorAndy Lutomirski <[email protected]>
Tue, 6 Oct 2015 00:47:50 +0000 (17:47 -0700)
committerIngo Molnar <[email protected]>
Wed, 7 Oct 2015 09:34:06 +0000 (11:34 +0200)
This should improve code quality a bit. It also shrinks the kernel text:

 Before:
       text     data      bss       dec    filename
   21828379  5194760  1277952  28301091    vmlinux

 After:
       text     data      bss       dec    filename
   21827997  5194760  1277952  28300709    vmlinux

... by 382 bytes.

Signed-off-by: Andy Lutomirski <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/f427b8002d932e5deab9055e0074bb4e7e80ee39.1444091584.git.luto@kernel.org
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/include/asm/uaccess.h

index 3e911c68876eebf8ae7c8dfe7e4f80b7bd6a0e78..09b1b0ab94b7653f7ed7019eb7e35b518582f825 100644 (file)
@@ -51,13 +51,13 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
         * limit, not add it to the address).
         */
        if (__builtin_constant_p(size))
-               return addr > limit - size;
+               return unlikely(addr > limit - size);
 
        /* Arbitrary sizes? Be careful about overflow */
        addr += size;
-       if (addr < size)
+       if (unlikely(addr < size))
                return true;
-       return addr > limit;
+       return unlikely(addr > limit);
 }
 
 #define __range_not_ok(addr, size, limit)                              \