Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/uaccess: Add unlikely() to __chk_range_not_ok() failure paths

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 <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/f427b8002d932e5deab9055e0074bb4e7e80ee39.1444091584.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
7e0f51cb a76cf66e

+3 -3
+3 -3
arch/x86/include/asm/uaccess.h
··· 51 51 * limit, not add it to the address). 52 52 */ 53 53 if (__builtin_constant_p(size)) 54 - return addr > limit - size; 54 + return unlikely(addr > limit - size); 55 55 56 56 /* Arbitrary sizes? Be careful about overflow */ 57 57 addr += size; 58 - if (addr < size) 58 + if (unlikely(addr < size)) 59 59 return true; 60 - return addr > limit; 60 + return unlikely(addr > limit); 61 61 } 62 62 63 63 #define __range_not_ok(addr, size, limit) \