Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755683AbbKRSXT (ORCPT ); Wed, 18 Nov 2015 13:23:19 -0500 Received: from mail.skyhub.de ([78.46.96.112]:47402 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719AbbKRSXR (ORCPT ); Wed, 18 Nov 2015 13:23:17 -0500 Date: Wed, 18 Nov 2015 19:23:04 +0100 From: Borislav Petkov To: Ingo Molnar Cc: X86 ML , LKML , Peter Zijlstra , Andy Lutomirski , Herbert Xu , Matt Mackall , Chris Mason , Josef Bacik , David Sterba Subject: Re: [RFC PATCH 3/3] x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros Message-ID: <20151118182304.GG4138@pd.tnic> References: <1447156122-9379-1-git-send-email-bp@alien8.de> <1447156122-9379-4-git-send-email-bp@alien8.de> <20151110123000.GA20227@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151110123000.GA20227@gmail.com> 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 Content-Length: 2976 Lines: 84 On Tue, Nov 10, 2015 at 01:30:00PM +0100, Ingo Molnar wrote: > > * Borislav Petkov wrote: > > > From: Borislav Petkov > > > > Those are stupid and code should use static_cpu_has_safe() anyway. Kill > > the least used and unused ones. > > So cpufeature.h doesn't really do a good job of explaining what the difference is > between all these variants: How's that for starters? --- diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 27ab2e7d14c4..a9a8313e278e 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -351,6 +351,10 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; (((bit)>>5)==8 && (1UL<<((bit)&31) & DISABLED_MASK8)) || \ (((bit)>>5)==9 && (1UL<<((bit)&31) & DISABLED_MASK9)) ) +/* + * Test whether the CPU represented by descriptor @c has the feature bit @bit + * set. + */ #define cpu_has(c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ test_cpu_cap(c, bit)) @@ -416,11 +420,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; extern void warn_pre_alternatives(void); extern bool __static_cpu_has_safe(u16 bit); -/* - * Static testing of CPU features. Used the same as boot_cpu_has(). - * These are only valid after alternatives have run, but will statically - * patch the target code for additional performance. - */ static __always_inline __pure bool __static_cpu_has(u16 bit) { #ifdef CC_HAVE_ASM_GOTO @@ -495,6 +494,18 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) #endif /* CC_HAVE_ASM_GOTO */ } +/* + * Test whether the boot CPU has feature bit @bit enabled. + * + * This is static testing of CPU features. It is used in the same manner as + * boot_cpu_has(). It is differs from the previous one in that the alternatives + * infrastructure will statically patch the code where the test is performed for + * additional performance. + * + * However, results from that macro are only valid after the alternatives have + * run and not before that. IOW, you want static_cpu_has_safe() instead, see + * below. + */ #define static_cpu_has(bit) \ ( \ __builtin_constant_p(boot_cpu_has(bit)) ? \ @@ -580,6 +591,11 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit) #endif /* CC_HAVE_ASM_GOTO */ } +/* + * Like static_cpu_has() above but it works even before the alternatives have + * run by falling back to boot_cpu_has(). You should use that macro for all your + * CPU feature bit testing needs. + */ #define static_cpu_has_safe(bit) \ ( \ __builtin_constant_p(boot_cpu_has(bit)) ? \ -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/