* [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers
@ 2024-04-09 4:20 Li RongQing
2024-04-09 7:45 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2024-04-09 4:20 UTC (permalink / raw)
To: tglx, mingo, bp, dave.hansen, x86, peterz, linux-kernel, pbonzini,
kvm, seanjc, szy0127, thomas.lendacky
Cc: Li RongQing
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@sjtu.edu.cn>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Li RongQing <lirongqing@baidu.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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers
2024-04-09 4:20 [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers Li RongQing
@ 2024-04-09 7:45 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2024-04-09 7:45 UTC (permalink / raw)
To: Li RongQing
Cc: tglx, mingo, bp, dave.hansen, x86, peterz, linux-kernel, pbonzini,
kvm, seanjc, szy0127, thomas.lendacky
* Li RongQing <lirongqing@baidu.com> wrote:
> 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@sjtu.edu.cn>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> arch/x86/include/asm/smp.h | 7 +++++++
> arch/x86/lib/cache-smp.c | 7 +++++++
> 2 files changed, 14 insertions(+)
The two patches should be submitted together within the same series.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-09 7:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09 4:20 [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers Li RongQing
2024-04-09 7:45 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox