public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] include/linux/log2.h: mark is_power_of_2() with __always_inline
@ 2025-02-21  7:16 Su Hui
  2025-02-24 15:57 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Su Hui @ 2025-02-21  7:16 UTC (permalink / raw)
  To: binbin.wu; +Cc: Su Hui, seanjc, pbonzini, linux-kernel, kernel-janitors, kvm

When build 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.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 include/linux/log2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index 9f30d087a128..1366cb688a6d 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -41,7 +41,7 @@ int __ilog2_u64(u64 n)
  * *not* considered a power of two.
  * Return: true if @n is a power of 2, otherwise false.
  */
-static inline __attribute__((const))
+static __always_inline __attribute__((const))
 bool is_power_of_2(unsigned long n)
 {
 	return (n != 0 && ((n & (n - 1)) == 0));
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-24 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21  7:16 [PATCH] include/linux/log2.h: mark is_power_of_2() with __always_inline Su Hui
2025-02-24 15:57 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox