From: François Tigeot Date: Sun, 9 Dec 2012 08:38:08 +0000 (+0100) Subject: kernel: Add cpu_wbinvd_on_all_cpus() X-Git-Tag: v3.4.0rc~709 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3c8aa76fc0a6e58ba8da17522bebe8a35631bd9f kernel: Add cpu_wbinvd_on_all_cpus() This function invalidates cache on all active cpus With-help-from: vsrinivas --- diff --git a/sys/cpu/i386/include/cpufunc.h b/sys/cpu/i386/include/cpufunc.h index 0dc9acf0d2..309d6ca71f 100644 --- a/sys/cpu/i386/include/cpufunc.h +++ b/sys/cpu/i386/include/cpufunc.h @@ -46,6 +46,8 @@ #ifndef _SYS_CDEFS_H_ #include #endif +#include +#include __BEGIN_DECLS #define readb(va) (*(volatile u_int8_t *) (va)) @@ -585,6 +587,16 @@ wbinvd(void) __asm __volatile("wbinvd"); } +#if defined(_KERNEL) +void cpu_wbinvd_on_all_cpus_callback(void *arg); + +static __inline void +cpu_wbinvd_on_all_cpus(void) +{ + lwkt_cpusync_simple(smp_active_mask, cpu_wbinvd_on_all_cpus_callback, NULL); +} +#endif + static __inline void write_eflags(u_int ef) { diff --git a/sys/cpu/x86_64/include/cpufunc.h b/sys/cpu/x86_64/include/cpufunc.h index 7a8fbcfda5..3cbb3cfcfc 100644 --- a/sys/cpu/x86_64/include/cpufunc.h +++ b/sys/cpu/x86_64/include/cpufunc.h @@ -45,7 +45,9 @@ #define _CPU_CPUFUNC_H_ #include +#include #include +#include struct thread; struct region_descriptor; @@ -562,6 +564,16 @@ wbinvd(void) __asm __volatile("wbinvd"); } +#if defined(_KERNEL) +void cpu_wbinvd_on_all_cpus_callback(void *arg); + +static __inline void +cpu_wbinvd_on_all_cpus(void) +{ + lwkt_cpusync_simple(smp_active_mask, cpu_wbinvd_on_all_cpus_callback, NULL); +} +#endif + static __inline void write_rflags(u_long rf) { diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index ac89595f88..f313d65cdf 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -846,6 +846,12 @@ smp_invltlb_intr(void) } } +void +cpu_wbinvd_on_all_cpus_callback(void *arg) +{ + wbinvd(); +} + /* * When called the executing CPU will send an IPI to all other CPUs * requesting that they halt execution. diff --git a/sys/platform/pc64/x86_64/mp_machdep.c b/sys/platform/pc64/x86_64/mp_machdep.c index b97cee9a9c..c4ef5795e4 100644 --- a/sys/platform/pc64/x86_64/mp_machdep.c +++ b/sys/platform/pc64/x86_64/mp_machdep.c @@ -865,6 +865,12 @@ smp_invltlb_intr(void) } } +void +cpu_wbinvd_on_all_cpus_callback(void *arg) +{ + wbinvd(); +} + /* * When called the executing CPU will send an IPI to all other CPUs * requesting that they halt execution.