Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Hide the MD details of specific IPIs behind semanti...



details:   https://anonhg.NetBSD.org/src/rev/700e471fa437
branches:  trunk
changeset: 768201:700e471fa437
user:      cherry <cherry%NetBSD.org@localhost>
date:      Thu Aug 11 18:11:17 2011 +0000

description:
Hide the MD details of specific IPIs behind semantically pleasing functions. This cleans up a couple of #ifdef XEN/#endif pairs

diffstat:

 sys/arch/amd64/amd64/machdep.c |  10 +++-------
 sys/arch/i386/i386/machdep.c   |  10 +++-------
 sys/arch/x86/include/cpu.h     |   4 +++-
 sys/arch/x86/x86/cpu.c         |  24 ++++++++++++++++++++++--
 sys/arch/x86/x86/x86_machdep.c |  22 +++++-----------------
 sys/arch/xen/x86/cpu.c         |  27 +++++++++++++++++++++++++--
 6 files changed, 61 insertions(+), 36 deletions(-)

diffs (224 lines):

diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $     */
+/*     $NetBSD: machdep.c,v 1.164 2011/08/11 18:11:17 cherry Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.164 2011/08/11 18:11:17 cherry Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -719,11 +719,7 @@
 #endif /* XEN */
        }
 
-#ifdef XEN
-       xen_broadcast_ipi(XEN_IPI_HALT);
-#else /* XEN */
-       x86_broadcast_ipi(X86_IPI_HALT);
-#endif
+       cpu_broadcast_halt();
 
        if (howto & RB_HALT) {
 #if NACPICA > 0
diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/i386/i386/machdep.c      Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry Exp $     */
+/*     $NetBSD: machdep.c,v 1.708 2011/08/11 18:11:17 cherry Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.708 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -955,11 +955,7 @@
        }
 
 #ifdef MULTIPROCESSOR
-#ifdef XEN
-       xen_broadcast_ipi(XEN_IPI_HALT);
-#else /* XEN */
-       x86_broadcast_ipi(X86_IPI_HALT);
-#endif /* XEN */
+       cpu_broadcast_halt();
 #endif /* MULTIPROCESSOR */
 
        if (howto & RB_HALT) {
diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/x86/include/cpu.h        Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.36 2011/08/10 06:40:35 cherry Exp $  */
+/*     $NetBSD: cpu.h,v 1.37 2011/08/11 18:11:17 cherry Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -314,6 +314,8 @@
 void cpu_init_idle_lwps(void);
 void cpu_init_msrs(struct cpu_info *, bool);
 void cpu_load_pmap(struct pmap *);
+void cpu_broadcast_halt(void);
+void cpu_kick(struct cpu_info *);
 
 extern uint32_t cpus_attached;
 
diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/x86/x86/cpu.c    Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $  */
+/*     $NetBSD: cpu.c,v 1.91 2011/08/11 18:11:17 cherry Exp $  */
 
 /*-
  * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.91 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -1210,3 +1210,23 @@
        lcr3(pmap_pdirpa(pmap, 0));
 #endif /* PAE */
 }
+
+/*
+ * Notify all other cpus to halt.
+ */
+
+void
+cpu_broadcast_halt(struct cpu_info *ci)
+{
+       x86_broadcast_ipi(X86_IPI_HALT);
+}
+
+/*
+ * Send a dummy ipi to a cpu to force it to run splraise()/spllower()
+ */
+
+void
+cpu_kick(struct cpu_info *ci)
+{
+       x86_send_ipi(ci, 0);
+}
diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $  */
+/*     $NetBSD: x86_machdep.c,v 1.55 2011/08/11 18:11:17 cherry Exp $  */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.55 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -205,11 +205,7 @@
                if (ci == cur)
                        return;
                if (x86_cpu_idle_ipi != false) {
-#ifdef XEN
-                       xen_send_ipi(ci, XEN_IPI_KICK);
-#else /* XEN */
-                       x86_send_ipi(ci, 0);
-#endif /* XEN */
+                       cpu_kick(ci);
                }
                return;
        }
@@ -231,11 +227,7 @@
                return;
        }
        if ((flags & RESCHED_IMMED) != 0) {
-#ifdef XEN
-               xen_send_ipi(ci, XEN_IPI_KICK);
-#else /* XEN */
-               x86_send_ipi(ci, 0);
-#endif /* XEN */
+               cpu_kick(ci);
        }
 }
 
@@ -246,11 +238,7 @@
        KASSERT(kpreempt_disabled());
        aston(l, X86_AST_GENERIC);
        if (l->l_cpu != curcpu())
-#ifdef XEN
-               xen_send_ipi(l->l_cpu, XEN_IPI_KICK);
-#else /* XEN */
-               x86_send_ipi(l->l_cpu, 0);
-#endif /* XEN */
+               cpu_kick(l->l_cpu);
 }
 
 void
diff -r 6dc54bdd32c9 -r 700e471fa437 sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c    Thu Aug 11 18:05:11 2011 +0000
+++ b/sys/arch/xen/x86/cpu.c    Thu Aug 11 18:11:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.60 2011/07/16 14:46:18 rmind Exp $   */
+/*     $NetBSD: cpu.c,v 1.61 2011/08/11 18:11:17 cherry Exp $  */
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.60 2011/07/16 14:46:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.61 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1177,3 +1177,26 @@
        }
 #endif /* __x86_64__ */
 }
+
+/*
+ * Notify all other cpus to halt.
+ */
+
+void
+cpu_broadcast_halt(void)
+{
+       xen_broadcast_ipi(XEN_IPI_HALT);
+}
+
+/*
+ * Send a dummy ipi to a cpu.
+ */
+
+void
+cpu_kick(struct cpu_info *ci)
+{
+       if (xen_send_ipi(ci, XEN_IPI_KICK) != 0) {
+               panic("xen_send_ipi(%s, XEN_IPI_KICK) failed\n",
+                   cpu_name(ci));
+       }
+}



Home | Main Index | Thread Index | Old Index