wbinvd_on_many_cpus will call smp_call_function_many(), which should be more efficient that iterating cpus since it would run wbinvd() concurrently locally and remotely it can be used by the below patch https://patchwork.kernel.org/project/kvm/patch/1860502863.219296.1710395908135.JavaMail.zimbra@xxxxxxxxxxx/ Cc: Zheyun Shen <szy0127@xxxxxxxxxxx> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx> Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx> --- arch/x86/include/asm/smp.h | 7 +++++++ arch/x86/lib/cache-smp.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a35936b..70973de 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -111,6 +111,7 @@ void native_play_dead(void); void play_dead_common(void); void wbinvd_on_cpu(int cpu); int wbinvd_on_all_cpus(void); +int wbinvd_on_many_cpus(const struct cpumask *mask); void smp_kick_mwait_play_dead(void); @@ -159,6 +160,12 @@ static inline int wbinvd_on_all_cpus(void) return 0; } +static inline int wbinvd_on_many_cpus(const struct cpumask *mask) +{ + wbinvd(); + return 0; +} + static inline struct cpumask *cpu_llc_shared_mask(int cpu) { return (struct cpumask *)cpumask_of(0); diff --git a/arch/x86/lib/cache-smp.c b/arch/x86/lib/cache-smp.c index 7af743b..5950d1b 100644 --- a/arch/x86/lib/cache-smp.c +++ b/arch/x86/lib/cache-smp.c @@ -20,3 +20,10 @@ int wbinvd_on_all_cpus(void) return 0; } EXPORT_SYMBOL(wbinvd_on_all_cpus); + +int wbinvd_on_many_cpus(const struct cpumask *mask) +{ + smp_call_function_many(mask, __wbinvd, NULL, 1); + return 0; +} +EXPORT_SYMBOL(wbinvd_on_many_cpus); -- 2.9.4