kernel: Add cpu_wbinvd_on_all_cpus()
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 9 Dec 2012 08:38:08 +0000 (09:38 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 9 Dec 2012 10:50:42 +0000 (11:50 +0100)
This function invalidates cache on all active cpus

With-help-from: vsrinivas

sys/cpu/i386/include/cpufunc.h
sys/cpu/x86_64/include/cpufunc.h
sys/platform/pc32/i386/mp_machdep.c
sys/platform/pc64/x86_64/mp_machdep.c

index 0dc9acf..309d6ca 100644 (file)
@@ -46,6 +46,8 @@
 #ifndef _SYS_CDEFS_H_
 #include <sys/cdefs.h>
 #endif
+#include <sys/thread.h>
+#include <machine/smp.h>
 
 __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)
 {
index 7a8fbcf..3cbb3cf 100644 (file)
@@ -45,7 +45,9 @@
 #define        _CPU_CPUFUNC_H_
 
 #include <sys/cdefs.h>
+#include <sys/thread.h>
 #include <machine/psl.h>
+#include <machine/smp.h>
 
 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)
 {
index ac89595..f313d65 100644 (file)
@@ -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.
index b97cee9..c4ef579 100644 (file)
@@ -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.