From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753167AbbEDNnW (ORCPT ); Mon, 4 May 2015 09:43:22 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:39537 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbbEDNnP (ORCPT ); Mon, 4 May 2015 09:43:15 -0400 Date: Mon, 4 May 2015 15:42:57 +0200 From: Peter Zijlstra To: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Linus Torvalds Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Jakub Jelinek Subject: Re: [PATCH] x86: Optimize variable_test_bit() Message-ID: <20150504134257.GA16478@twins.programming.kicks-ass.net> References: <20150501151630.GH5029@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150501151630.GH5029@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 01, 2015 at 05:16:30PM +0200, Peter Zijlstra wrote: > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h > index cfe3b954d5e4..bcf4fa77c04f 100644 > --- a/arch/x86/include/asm/bitops.h > +++ b/arch/x86/include/asm/bitops.h > @@ -313,6 +313,15 @@ static __always_inline int constant_test_bit(long nr, const volatile unsigned lo > > static inline int variable_test_bit(long nr, volatile const unsigned long *addr) > { > +#ifdef CC_HAVE_ASM_GOTO > + asm_volatile_goto ("bt %1, %0\n\t" > + "jc %l[cc_label]" > + : : "m" (*(unsigned long *)addr), "Ir" (nr) > + : : cc_label); > + return 0; > +cc_label: > + return 1; > +#else I figured I'd try both jc and jnc versions: text data bss dec hex filename 12203914 1738112 1081344 15023370 e53d0a defconfig-build/vmlinux 12204228 1738112 1081344 15023684 e53e44 defconfig-build/vmlinux-jc 12203240 1738112 1081344 15022696 e53a68 defconfig-build/vmlinux-jnc Clearly I picked the wrong one :-) It also shows there is real value in exposing this decision to GCC.