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, Jan 10, 2022 at 11:27:09PM +0000, Sean Christopherson wrote:
>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.

This makes sense.

>More than once I've wondered why some bit of code isn't __init, only to realize
>its used for hotplug.

Same problem to some global data structures which can be __initdata if hotplug
isn't supported.

>
>What if we added an __init_or_hotplug annotation that is a nop if HOTPLUG_CPU=y?

Personally __init_or_hotplug is a little long as an annotation. How about
__hotplug?

One concern is: is it acceptable to introduce a new annotation and use it in
new code but not fix all places that should use it in existing code.

I think the right process is
1. introduce a new annotation
2. fix existing code to use this annotation
3. add new code.

There is no doubt that #2 would take great effort. I'm not sure if it is really
worth it.

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

Will do with your suggested-by.

>
>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