From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754544AbbJGQX2 (ORCPT ); Wed, 7 Oct 2015 12:23:28 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:33871 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbbJGQX1 (ORCPT ); Wed, 7 Oct 2015 12:23:27 -0400 Date: Wed, 7 Oct 2015 18:23:23 +0200 From: Ingo Molnar To: Borislav Petkov Cc: Andy Lutomirski , x86@kernel.org, linux-kernel@vger.kernel.org, Brian Gerst , Denys Vlasenko , Linus Torvalds Subject: Re: [PATCH v2 02/36] x86/uaccess: __chk_range_not_ok is unlikely to return true Message-ID: <20151007162323.GB8738@gmail.com> References: <20151007105934.GB5046@nazgul.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151007105934.GB5046@nazgul.tnic> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Borislav Petkov wrote: > On Mon, Oct 05, 2015 at 05:47:50PM -0700, Andy Lutomirski wrote: > > This should improve code quality a bit. It also shrinks the kernel > > text. > > > > Before: > > text data bss dec hex filename > > 21828379 5194760 1277952 28301091 1afd723 vmlinux > > text data bss dec hex filename > > 21827997 5194760 1277952 28300709 1afd5a5 vmlinux > > > > Signed-off-by: Andy Lutomirski > > --- > > arch/x86/include/asm/uaccess.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > > index 3e911c68876e..09b1b0ab94b7 100644 > > --- a/arch/x86/include/asm/uaccess.h > > +++ b/arch/x86/include/asm/uaccess.h > > @@ -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); > > It certainly uglifies it though. Are the wins worth the (un-)readability > hit? Well, adding likely/unlikely hints in headers is OK I think, especially since these are performance sensitive user-access routines. Thanks, Ingo