Source-Changes-HG archive

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

[src/netbsd-6]: src/sys Pull up following revision(s) (requested by rmind in ...



details:   https://anonhg.NetBSD.org/src/rev/b3ad3148b9ff
branches:  netbsd-6
changeset: 774197:b3ad3148b9ff
user:      riz <riz%NetBSD.org@localhost>
date:      Tue Jun 12 19:00:24 2012 +0000

description:
Pull up following revision(s) (requested by rmind in ticket #314):
        sys/arch/xen/x86/cpu.c: revision 1.92
        sys/kern/subr_kcpuset.c: revision 1.6
        sys/sys/kcpuset.h: revision 1.6
        sys/arch/xen/x86/x86_xpmap.c: revision 1.44
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 7fffc971e9ae -r b3ad3148b9ff sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c    Tue Jun 12 18:31:30 2012 +0000
+++ b/sys/arch/xen/x86/cpu.c    Tue Jun 12 19:00:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.80.2.4 2012/05/09 03:22:53 riz Exp $ */
+/*     $NetBSD: cpu.c,v 1.80.2.5 2012/06/12 19:00:24 riz 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.80.2.4 2012/05/09 03:22:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.80.2.5 2012/06/12 19:00:24 riz Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1156,10 +1156,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
@@ -1218,9 +1219,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 7fffc971e9ae -r b3ad3148b9ff sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c      Tue Jun 12 18:31:30 2012 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c      Tue Jun 12 19:00:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_xpmap.c,v 1.38.2.4 2012/05/09 03:22:54 riz Exp $   */
+/*     $NetBSD: x86_xpmap.c,v 1.38.2.5 2012/06/12 19:00:25 riz 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.38.2.4 2012/05/09 03:22:54 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.38.2.5 2012/06/12 19:00:25 riz Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -360,32 +360,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();
 
@@ -422,9 +404,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 7fffc971e9ae -r b3ad3148b9ff sys/kern/subr_kcpuset.c
--- a/sys/kern/subr_kcpuset.c   Tue Jun 12 18:31:30 2012 +0000
+++ b/sys/kern/subr_kcpuset.c   Tue Jun 12 19:00:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_kcpuset.c,v 1.4.2.1 2012/05/09 03:22:54 riz Exp $ */
+/*     $NetBSD: subr_kcpuset.c,v 1.4.2.2 2012/06/12 19:00:25 riz 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.4.2.1 2012/05/09 03:22:54 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kcpuset.c,v 1.4.2.2 2012/06/12 19:00:25 riz 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 7fffc971e9ae -r b3ad3148b9ff sys/sys/kcpuset.h
--- a/sys/sys/kcpuset.h Tue Jun 12 18:31:30 2012 +0000
+++ b/sys/sys/kcpuset.h Tue Jun 12 19:00:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kcpuset.h,v 1.4.2.1 2012/05/09 03:22:54 riz Exp $      */
+/*     $NetBSD: kcpuset.h,v 1.4.2.2 2012/06/12 19:00:26 riz 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