[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240409042056.51757-1-lirongqing@baidu.com>
Date: Tue, 9 Apr 2024 12:20:56 +0800
From: Li RongQing <lirongqing@...du.com>
To: tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
peterz@...radead.org,
linux-kernel@...r.kernel.org,
pbonzini@...hat.com,
kvm@...r.kernel.org,
seanjc@...gle.com,
szy0127@...u.edu.cn,
thomas.lendacky@....com
Cc: Li RongQing <lirongqing@...du.com>
Subject: [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers
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@sjtu.edu.cn/
Cc: Zheyun Shen <szy0127@...u.edu.cn>
Cc: Tom Lendacky <thomas.lendacky@....com>
Signed-off-by: Li RongQing <lirongqing@...du.com>
---
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
Powered by blists - more mailing lists