Skip to content

Commit c29564d

Browse files
Su Huiakpm00
authored andcommitted
include/linux/log2.h: mark is_power_of_2() with __always_inline
When building kernel with randconfig, there is an error: In function `kvm_is_cr4_bit_set',inlined from `kvm_update_cpuid_runtime' at arch/x86/kvm/cpuid.c:310:9: include/linux/compiler_types.h:542:38: error: call to `__compiletime_assert_380' declared with attribute error: BUILD_BUG_ON failed: !is_power_of_2(cr4_bit). '!is_power_of_2(X86_CR4_OSXSAVE)' is False, but gcc treats is_power_of_2() as non-inline function and a compilation error happens. Fix this by marking is_power_of_2() with __always_inline. Link: https://lkml.kernel.org/r/20250221071624.1356899-1-suhui@nfschina.com Signed-off-by: Su Hui <suhui@nfschina.com> Cc: Binbin Wu <binbin.wu@linux.intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent ce6d9c1 commit c29564d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/log2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int __ilog2_u64(u64 n)
4141
* *not* considered a power of two.
4242
* Return: true if @n is a power of 2, otherwise false.
4343
*/
44-
static inline __attribute__((const))
44+
static __always_inline __attribute__((const))
4545
bool is_power_of_2(unsigned long n)
4646
{
4747
return (n != 0 && ((n & (n - 1)) == 0));

0 commit comments

Comments
 (0)