Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/cherry-xenmp]: src/sys/arch/xen Use an IPI to re-route events to the cpu...
details: https://anonhg.NetBSD.org/src/rev/30e05c0434fd
branches: cherry-xenmp
changeset: 765642:30e05c0434fd
user: cherry <cherry%NetBSD.org@localhost>
date: Sun Sep 18 18:46:40 2011 +0000
description:
Use an IPI to re-route events to the cpu where the handler has been registered
diffstat:
sys/arch/xen/include/hypervisor.h | 6 +++---
sys/arch/xen/include/intrdefs.h | 5 +++--
sys/arch/xen/x86/hypervisor_machdep.c | 34 ++++++++++++++++++++++++++++++++--
sys/arch/xen/x86/xen_ipi.c | 29 ++++++++++++++++++++++-------
sys/arch/xen/xen/evtchn.c | 21 +++++++++------------
5 files changed, 69 insertions(+), 26 deletions(-)
diffs (216 lines):
diff -r 4444a5ac5622 -r 30e05c0434fd sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h Sun Sep 18 16:48:23 2011 +0000
+++ b/sys/arch/xen/include/hypervisor.h Sun Sep 18 18:46:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.h,v 1.31.10.2 2011/08/20 19:22:47 cherry Exp $ */
+/* $NetBSD: hypervisor.h,v 1.31.10.3 2011/09/18 18:46:40 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -134,12 +134,12 @@
void hypervisor_enable_event(unsigned int);
/* hypervisor_machdep.c */
+void hypervisor_send_event(struct cpu_info *, unsigned int);
void hypervisor_unmask_event(unsigned int);
void hypervisor_mask_event(unsigned int);
void hypervisor_clear_event(unsigned int);
void hypervisor_enable_ipl(unsigned int);
-void hypervisor_set_ipending(struct cpu_info *,
- uint32_t, int, int);
+void hypervisor_set_ipending(struct cpu_info *, uint32_t, int, int);
void hypervisor_machdep_attach(void);
/*
diff -r 4444a5ac5622 -r 30e05c0434fd sys/arch/xen/include/intrdefs.h
--- a/sys/arch/xen/include/intrdefs.h Sun Sep 18 16:48:23 2011 +0000
+++ b/sys/arch/xen/include/intrdefs.h Sun Sep 18 18:46:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intrdefs.h,v 1.9.34.2 2011/06/03 13:27:40 cherry Exp $ */
+/* $NetBSD: intrdefs.h,v 1.9.34.3 2011/09/18 18:46:40 cherry Exp $ */
/* This file co-exists, and is included via machine/intrdefs.h */
@@ -11,7 +11,8 @@
#define XEN_IPI_SYNCH_FPU 0x00000002
#define XEN_IPI_DDB 0x00000004
#define XEN_IPI_XCALL 0x00000008
+#define XEN_IPI_HVCB 0x00000010
-#define XEN_NIPIS 4 /* IPI_KICK doesn't have a handler */
+#define XEN_NIPIS 5 /* IPI_KICK doesn't have a handler */
#endif /* _XEN_INTRDEFS_H_ */
diff -r 4444a5ac5622 -r 30e05c0434fd sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c Sun Sep 18 16:48:23 2011 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c Sun Sep 18 18:46:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $ */
+/* $NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $ */
/*
*
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -281,6 +281,36 @@
}
void
+hypervisor_send_event(struct cpu_info *ci, unsigned int ev)
+{
+ KASSERT(ci != NULL);
+
+ volatile shared_info_t *s = HYPERVISOR_shared_info;
+ volatile struct vcpu_info *vci = ci->ci_vcpu;
+
+#ifdef PORT_DEBUG
+ if (ev == PORT_DEBUG)
+ printf("hypervisor_send_event %d\n", ev);
+#endif
+
+ xen_atomic_set_bit(&s->evtchn_pending[0], ev);
+ xen_atomic_set_bit(&vci->evtchn_pending_sel,
+ ev >> LONG_SHIFT);
+
+ xen_atomic_set_bit(&vci->evtchn_upcall_pending, 0);
+
+ xen_atomic_clear_bit(&s->evtchn_mask[0], ev);
+
+ if (__predict_true(ci == curcpu())) {
+ hypervisor_force_callback();
+ } else {
+ if (xen_send_ipi(ci, XEN_IPI_HVCB)) {
+ panic("xen_send_ipi(cpu%d, XEN_IPI_HVCB) failed\n", (int) ci->ci_cpuid);
+ }
+ }
+}
+
+void
hypervisor_unmask_event(unsigned int ev)
{
volatile shared_info_t *s = HYPERVISOR_shared_info;
diff -r 4444a5ac5622 -r 30e05c0434fd sys/arch/xen/x86/xen_ipi.c
--- a/sys/arch/xen/x86/xen_ipi.c Sun Sep 18 16:48:23 2011 +0000
+++ b/sys/arch/xen/x86/xen_ipi.c Sun Sep 18 18:46:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.1.2.3 2011/08/17 09:40:40 cherry Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.1.2.4 2011/09/18 18:46:40 cherry Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,10 +33,10 @@
/*
* Based on: x86/ipi.c
- * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.1.2.3 2011/08/17 09:40:40 cherry Exp $");
+ * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.1.2.4 2011/09/18 18:46:40 cherry Exp $");
*/
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.1.2.3 2011/08/17 09:40:40 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.1.2.4 2011/09/18 18:46:40 cherry Exp $");
#include <sys/types.h>
@@ -72,13 +72,15 @@
static void xen_ipi_synch_fpu(struct cpu_info *, struct intrframe *);
static void xen_ipi_ddb(struct cpu_info *, struct intrframe *);
static void xen_ipi_xcall(struct cpu_info *, struct intrframe *);
+static void xen_ipi_hvcb(struct cpu_info *, struct intrframe *);
static void (*ipifunc[XEN_NIPIS])(struct cpu_info *, struct intrframe *) =
{ /* In order of priority (see: xen/include/intrdefs.h */
xen_ipi_halt,
xen_ipi_synch_fpu,
xen_ipi_ddb,
- xen_ipi_xcall
+ xen_ipi_xcall,
+ xen_ipi_hvcb
};
static void
@@ -139,9 +141,9 @@
static inline bool /* helper */
valid_ipimask(uint32_t ipimask)
{
- uint32_t masks = XEN_IPI_XCALL | XEN_IPI_DDB |
- XEN_IPI_SYNCH_FPU | XEN_IPI_HALT |
- XEN_IPI_KICK;
+ uint32_t masks = XEN_IPI_HVCB | XEN_IPI_XCALL |
+ XEN_IPI_DDB | XEN_IPI_SYNCH_FPU |
+ XEN_IPI_HALT | XEN_IPI_KICK;
if (ipimask & ~masks) {
return false;
@@ -296,3 +298,16 @@
xen_broadcast_ipi(XEN_IPI_XCALL);
}
}
+
+static void
+xen_ipi_hvcb(struct cpu_info *ci, struct intrframe *intrf)
+{
+ KASSERT(ci != NULL);
+ KASSERT(intrf != NULL);
+
+ volatile struct vcpu_info *vci = ci->ci_vcpu;
+
+ KASSERT(ci == curcpu());
+ KASSERT(!vci->evtchn_upcall_mask);
+ hypervisor_force_callback();
+}
diff -r 4444a5ac5622 -r 30e05c0434fd sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Sun Sep 18 16:48:23 2011 +0000
+++ b/sys/arch/xen/xen/evtchn.c Sun Sep 18 18:46:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: evtchn.c,v 1.47.6.4 2011/08/17 09:40:40 cherry Exp $ */
+/* $NetBSD: evtchn.c,v 1.47.6.5 2011/09/18 18:46:40 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.47.6.4 2011/08/17 09:40:40 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.47.6.5 2011/09/18 18:46:40 cherry Exp $");
#include "opt_xen.h"
#include "isa.h"
@@ -237,8 +237,13 @@
ci->ci_data.cpu_nintr++;
evtsource[evtch]->ev_evcnt.ev_count++;
ilevel = ci->ci_ilevel;
- if (evtsource[evtch]->ev_maxlevel <= ilevel ||
- evtsource[evtch]->ev_cpu != ci /* XXX: get stats */) {
+
+ if (evtsource[evtch]->ev_cpu != ci /* XXX: get stats */) {
+ hypervisor_send_event(evtsource[evtch]->ev_cpu, evtch);
+ return 0;
+ }
+
+ if (evtsource[evtch]->ev_maxlevel <= ilevel) {
#ifdef IRQ_DEBUG
if (evtch == IRQ_DEBUG)
printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n",
@@ -249,14 +254,6 @@
evtch >> LONG_SHIFT,
evtch & LONG_MASK);
- if (evtsource[evtch]->ev_cpu != ci) {
- /* facilitate spllower() on remote cpu */
- struct cpu_info *rci = evtsource[evtch]->ev_cpu;
- if (xen_send_ipi(rci, XEN_IPI_KICK) != 0) {
- panic("xen_send_ipi(%s, XEN_IPI_KICK) failed\n", cpu_name(rci));
- }
- }
-
/* leave masked */
return 0;
}
Home |
Main Index |
Thread Index |
Old Index