Re: [PATCH v6 01/11] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT

From: Kuppuswamy, Sathyanarayanan
Date: Fri Sep 03 2021 - 15:04:03 EST




On 9/3/21 11:22 AM, Borislav Petkov wrote:
On Fri, Sep 03, 2021 at 10:28:02AM -0700, Kuppuswamy Sathyanarayanan wrote:
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
index c5ce9845c999..ddc77c95adc6 100644
--- a/arch/x86/include/asm/irqflags.h
+++ b/arch/x86/include/asm/irqflags.h
@@ -59,27 +59,8 @@ static inline __cpuidle void native_halt(void)
#endif
-#ifdef CONFIG_PARAVIRT_XXL
-#include <asm/paravirt.h>
-#else
+#ifndef CONFIG_PARAVIRT
#ifndef __ASSEMBLY__
-#include <linux/types.h>
-
-static __always_inline unsigned long arch_local_save_flags(void)
-{
- return native_save_fl();
-}
-
-static __always_inline void arch_local_irq_disable(void)
-{
- native_irq_disable();
-}
-
-static __always_inline void arch_local_irq_enable(void)
-{
- native_irq_enable();
-}
-
/*
* Used in the idle loop; sti takes one instruction cycle
* to complete:
@@ -97,6 +78,33 @@ static inline __cpuidle void halt(void)
{
native_halt();
}
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_PARAVIRT */
+
+#ifdef CONFIG_PARAVIRT
+#ifndef __ASSEMBLY__
+#include <asm/paravirt.h>
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_PARAVIRT */

I think the way we write those is like this:

#ifdef CONFIG_PARAVIRT

# ifndef __ASSEMBLY__
# include <asm/paravirt.h>
# endif

#else /* ! CONFIG_PARAVIRT */

# ifndef __ASSEMBLY__
/*
* Used in the idle loop; sti takes one instruction cycle
* to complete:
*/
static inline __cpuidle void arch_safe_halt(void)
{
native_safe_halt();
}

/*
* Used when interrupts are already enabled or to
* shutdown the processor:
*/
static inline __cpuidle void halt(void)
{
native_halt();
}
# endif /* __ASSEMBLY__ */

#endif /* CONFIG_PARAVIRT */

Yes, I can combine the #ifdef as you have mentioned. I can fix this
in next version.


Note the empty space after the '#' of the inner ifdef to show that it is
an inner one.

Is this new convention? #ifdefs used in this file does not follow this
format.

--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer