Re: [PATCH 1/6] KVM: x86: Move check_processor_compatibility from init ops to runtime ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 27, 2021, Chao Gao wrote:
> so that KVM can do compatibility checks on hotplugged CPUs. Drop __init
> from check_processor_compatibility() and its callees.

Losing the __init annotation on all these helpers makes me a bit sad, more from a
documentation perspective than a "but we could shave a few bytes" perspective.
More than once I've wondered why some bit of code isn't __init, only to realize
its used for hotplug.

What if we added an __init_or_hotplug annotation that is a nop if HOTPLUG_CPU=y?
At a glance, KVM could use that if the guts of kvm_online_cpu() were #idef'd out
on !CONFIG_HOTPLUG_CPU.  That also give us a bit of test coverage for bots that
build with SMP=n.

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a80e3b0c11a8..30bbcb4f4057 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11380,7 +11380,7 @@ void kvm_arch_hardware_unsetup(void)
        static_call(kvm_x86_hardware_unsetup)();
 }

-int kvm_arch_check_processor_compat(void)
+int __init_or_hotplug kvm_arch_check_processor_compat(void)
 {
        struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());

diff --git a/include/linux/init.h b/include/linux/init.h
index d82b4b2e1d25..33788b3c180a 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -53,6 +53,12 @@
 #define __exitdata     __section(".exit.data")
 #define __exit_call    __used __section(".exitcall.exit")

+#ifdef CONFIG_HOTPLUG_CPU
+#define __init_or_hotplug
+#else
+#define __init_or_hotplug __init
+#endif /* CONFIG_HOTPLUG_CPU
+
 /*
  * modpost check for section mismatches during the kernel build.
  * A section mismatch happens when there are references from a




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux