Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Few fixes for Xen:
details: https://anonhg.NetBSD.org/src/rev/072e40c871cb
branches: trunk
changeset: 779634:072e40c871cb
user: rmind <rmind%NetBSD.org@localhost>
date: Wed Jun 06 22:22:41 2012 +0000
description:
Few fixes for Xen:
- cpu_load_pmap: use atomic kcpuset(9) operations; fixes rare crashes.
- Add kcpuset_copybits(9) and replace xen_kcpuset2bits(). Avoids incorrect
ncpu problem in early boot. Also, micro-optimises xen_mcast_invlpg() and
xen_mcast_tlbflush() routines.
Tested by chs@.
diffstat:
sys/arch/xen/x86/cpu.c | 13 +++++++------
sys/arch/xen/x86/x86_xpmap.c | 32 ++++++++------------------------
sys/kern/subr_kcpuset.c | 13 +++++++++++--
sys/sys/kcpuset.h | 3 ++-
4 files changed, 28 insertions(+), 33 deletions(-)
diffs (162 lines):
diff -r fbfb72a46291 -r 072e40c871cb sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c Wed Jun 06 21:23:10 2012 +0000
+++ b/sys/arch/xen/x86/cpu.c Wed Jun 06 22:22:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.91 2012/04/20 22:23:25 rmind Exp $ */
+/* $NetBSD: cpu.c,v 1.92 2012/06/06 22:22:41 rmind 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.91 2012/04/20 22:23:25 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.92 2012/06/06 22:22:41 rmind Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -1110,10 +1110,11 @@
#if defined(__x86_64__) || defined(PAE)
struct cpu_info *ci = curcpu();
+ cpuid_t cid = cpu_index(ci);
mutex_enter(&ci->ci_kpm_mtx);
/* make new pmap visible to pmap_kpm_sync_xcall() */
- kcpuset_set(pmap->pm_xen_ptp_cpus, cpu_index(ci));
+ kcpuset_atomic_set(pmap->pm_xen_ptp_cpus, cid);
#endif
#ifdef i386
#ifdef PAE
@@ -1166,9 +1167,9 @@
#endif /* __x86_64__ */
#if defined(__x86_64__) || defined(PAE)
/* old pmap no longer visible to pmap_kpm_sync_xcall() */
- if (oldpmap != pmap_kernel())
- kcpuset_clear(oldpmap->pm_xen_ptp_cpus, cpu_index(ci));
-
+ if (oldpmap != pmap_kernel()) {
+ kcpuset_atomic_clear(oldpmap->pm_xen_ptp_cpus, cid);
+ }
mutex_exit(&ci->ci_kpm_mtx);
#endif
}
diff -r fbfb72a46291 -r 072e40c871cb sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c Wed Jun 06 21:23:10 2012 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c Wed Jun 06 22:22:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_xpmap.c,v 1.43 2012/04/20 22:23:25 rmind Exp $ */
+/* $NetBSD: x86_xpmap.c,v 1.44 2012/06/06 22:22:41 rmind Exp $ */
/*
* Copyright (c) 2006 Mathieu Ropert <mro%adviseo.fr@localhost>
@@ -69,7 +69,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.43 2012/04/20 22:23:25 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.44 2012/06/06 22:22:41 rmind Exp $");
#include "opt_xen.h"
#include "opt_ddb.h"
@@ -361,32 +361,14 @@
panic("xpq_queue_invlpg");
}
-#if defined(_LP64) && MAXCPUS > 64
-#error "XEN/amd64 uses 64 bit masks"
-#elsif !defined(_LP64) && MAXCPUS > 32
-#error "XEN/i386 uses 32 bit masks"
-#else
-/* XXX: Inefficient. */
-static u_long
-xen_kcpuset2bits(kcpuset_t *kc)
-{
- u_long bits = 0;
-
- for (cpuid_t i = 0; i < ncpu; i++) {
- if (kcpuset_isset(kc, i)) {
- bits |= 1 << i;
- }
- }
- return bits;
-}
-#endif
-
void
xen_mcast_invlpg(vaddr_t va, kcpuset_t *kc)
{
- u_long xcpumask = xen_kcpuset2bits(kc);
+ u_long xcpumask = 0;
mmuext_op_t op;
+ kcpuset_copybits(kc, &xcpumask, sizeof(xcpumask));
+
/* Flush pending page updates */
xpq_flush_queue();
@@ -423,9 +405,11 @@
void
xen_mcast_tlbflush(kcpuset_t *kc)
{
- u_long xcpumask = xen_kcpuset2bits(kc);
+ u_long xcpumask = 0;
mmuext_op_t op;
+ kcpuset_copybits(kc, &xcpumask, sizeof(xcpumask));
+
/* Flush pending page updates */
xpq_flush_queue();
diff -r fbfb72a46291 -r 072e40c871cb sys/kern/subr_kcpuset.c
--- a/sys/kern/subr_kcpuset.c Wed Jun 06 21:23:10 2012 +0000
+++ b/sys/kern/subr_kcpuset.c Wed Jun 06 22:22:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kcpuset.c,v 1.5 2012/04/20 22:23:25 rmind Exp $ */
+/* $NetBSD: subr_kcpuset.c,v 1.6 2012/06/06 22:22:41 rmind Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kcpuset.c,v 1.5 2012/04/20 22:23:25 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kcpuset.c,v 1.6 2012/06/06 22:22:41 rmind Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -301,6 +301,15 @@
return copyout(kcp, ucp, len);
}
+void
+kcpuset_copybits(const kcpuset_t *kcp, void *bitfield, size_t len)
+{
+ size_t rlen = MIN(kc_bitsize, len);
+
+ KASSERT(kcp != NULL);
+ memcpy(bitfield, kcp->bits, rlen);
+}
+
/*
* Routines to change bit field - zero, fill, copy, set, unset, etc.
*/
diff -r fbfb72a46291 -r 072e40c871cb sys/sys/kcpuset.h
--- a/sys/sys/kcpuset.h Wed Jun 06 21:23:10 2012 +0000
+++ b/sys/sys/kcpuset.h Wed Jun 06 22:22:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kcpuset.h,v 1.5 2012/04/20 22:23:25 rmind Exp $ */
+/* $NetBSD: kcpuset.h,v 1.6 2012/06/06 22:22:41 rmind Exp $ */
/*-
* Copyright (c) 2008, 2011 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
int kcpuset_copyin(const cpuset_t *, kcpuset_t *, size_t);
int kcpuset_copyout(kcpuset_t *, cpuset_t *, size_t);
+void kcpuset_copybits(const kcpuset_t *, void *, size_t);
void kcpuset_zero(kcpuset_t *);
void kcpuset_fill(kcpuset_t *);
Home |
Main Index |
Thread Index |
Old Index