On Sat, May 17, 2025, Ingo Molnar wrote: > > * Sean Christopherson <sea...@google.com> wrote: > > > From: Zheyun Shen <szy0...@sjtu.edu.cn> > > > > Extract KVM's open-coded calls to do writeback caches on multiple CPUs to > > common library helpers for both WBINVD and WBNOINVD (KVM will use both). > > Put the onus on the caller to check for a non-empty mask to simplify the > > SMP=n implementation, e.g. so that it doesn't need to check that the one > > and only CPU in the system is present in the mask. > > > > Signed-off-by: Zheyun Shen <szy0...@sjtu.edu.cn> > > Reviewed-by: Tom Lendacky <thomas.lenda...@amd.com> > > Link: https://lore.kernel.org/r/20250128015345.7929-2-szy0...@sjtu.edu.cn > > [sean: move to lib, add SMP=n helpers, clarify usage] > > Acked-by: Kai Huang <kai.hu...@intel.com> > > Signed-off-by: Sean Christopherson <sea...@google.com> > > --- > > arch/x86/include/asm/smp.h | 12 ++++++++++++ > > arch/x86/kvm/x86.c | 8 +------- > > arch/x86/lib/cache-smp.c | 12 ++++++++++++ > > 3 files changed, 25 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > > index e08f1ae25401..fe98e021f7f8 100644 > > --- a/arch/x86/include/asm/smp.h > > +++ b/arch/x86/include/asm/smp.h > > @@ -113,7 +113,9 @@ void native_play_dead(void); > > void play_dead_common(void); > > void wbinvd_on_cpu(int cpu); > > void wbinvd_on_all_cpus(void); > > +void wbinvd_on_many_cpus(struct cpumask *cpus); > > void wbnoinvd_on_all_cpus(void); > > +void wbnoinvd_on_many_cpus(struct cpumask *cpus); > > Let's go with the _on_cpumask() suffix: > > void wbinvd_on_cpu(int cpu); > +void wbinvd_on_cpumask(struct cpumask *cpus); > void wbinvd_on_all_cpus(void); > > And the wb*invd_all_cpus() methods should probably be inlined wrappers > with -1 as the cpumask, or so - not two separate functions?
Using two separate functions allows _on_all_cpus() to defer the mask generation to on_each_cpu(), i.e. avoids having to duplicate the passing of cpu_online_mask. IMO, duplicating passing __wbinvd is preferable to duplicating the use of cpu_online_mask. > In fact it would be nice to have the DRM preparatory patch and all the > x86 patches at the beginning of the next version of the series, so > those 4 patches can be applied to the x86 tree. Can make it a separate > permanent branch based on v6.15-rc6/rc7. Can do, assuming there's no lurking dependency I'm missing.