Re: [PATCH v2 1/1] x86/reboot: KVM: Guard nmi_shootdown_cpus_on_restart() with ifdeffery

From: Andy Shevchenko
Date: Wed Oct 09 2024 - 19:38:20 EST


Wed, Oct 09, 2024 at 12:34:37PM -0700, Sean Christopherson kirjoitti:
> On Tue, Oct 08, 2024, Andy Shevchenko wrote:
> > The nmi_shootdown_cpus_on_restart() in some cases may be not used.
> > This, in particular, prevents kernel builds with clang, `make W=1`
> > and CONFIG_WERROR=y:
> >
> > arch/x86/kernel/reboot.c:957:20: error: unused function 'nmi_shootdown_cpus_on_restart' [-Werror,-Wunused-function]
> > 957 | static inline void nmi_shootdown_cpus_on_restart(void)
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Fix this by guarging the definitions with the respective KVM ifdeffery.
> >
> > See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> > inline functions for W=1 build").

> Heh, I tried fixing this too, and have patches to clean things up, but I ended up
> not posting them because I decided the W=1 warning was less ugly than the resulting
> code in nmi_shootdown_cpus().

CONFIG_WERROR=y is the default (at least in the current defconfigs for x86).
My goal is to match what ARM builds survive (to some extend?), i.e. W=1, so
may one apply either version I provided or yours?

> If we're willing to take on a bit of weirdness in nmi_shootdown_cpus(), then much
> of the #ifdeffery can go away. Patches attached (lightly tested).

--
With Best Regards,
Andy Shevchenko