Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch A few changes:
details: https://anonhg.NetBSD.org/src/rev/f2f23de83fd8
branches: trunk
changeset: 351976:f2f23de83fd8
user: maxv <maxv%NetBSD.org@localhost>
date: Wed Mar 08 18:00:49 2017 +0000
description:
A few changes:
* Use markers to reduce false sharing.
* Remove XENDEBUG_SYNC and several debug messages, they are just useless.
* Remove xen_vcpu_*. They are unused and not optimized: if we really
wanted to flush ranges we should pack the VAs in a mmuext_op array
instead of performing several hypercalls in a loop.
* Start removing PG_k.
* KNF, reorder, simplify and remove stupid comments.
diffstat:
sys/arch/amd64/conf/ALL | 5 +-
sys/arch/i386/conf/ALL | 5 +-
sys/arch/xen/include/xenpmap.h | 4 +-
sys/arch/xen/x86/x86_xpmap.c | 213 ++++++++++++++--------------------------
4 files changed, 82 insertions(+), 145 deletions(-)
diffs (truncated from 598 to 300 lines):
diff -r a78f026502ce -r f2f23de83fd8 sys/arch/amd64/conf/ALL
--- a/sys/arch/amd64/conf/ALL Wed Mar 08 17:06:35 2017 +0000
+++ b/sys/arch/amd64/conf/ALL Wed Mar 08 18:00:49 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.53 2017/02/26 12:03:14 rin Exp $
+# $NetBSD: ALL,v 1.54 2017/03/08 18:00:49 maxv Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.53 $"
+#ident "ALL-$Revision: 1.54 $"
maxusers 64 # estimated number of users
@@ -2334,7 +2334,6 @@
options XENDEBUG
options XENDEBUG_LOW
options XENDEBUG_NET
-options XENDEBUG_SYNC
options XENDEBUG_VBD
options XENNET_DEBUG
options XENNET_DEBUG_DUMP
diff -r a78f026502ce -r f2f23de83fd8 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL Wed Mar 08 17:06:35 2017 +0000
+++ b/sys/arch/i386/conf/ALL Wed Mar 08 18:00:49 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.414 2017/02/26 12:03:14 rin Exp $
+# $NetBSD: ALL,v 1.415 2017/03/08 18:00:49 maxv Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.414 $"
+#ident "ALL-$Revision: 1.415 $"
maxusers 64 # estimated number of users
@@ -2533,7 +2533,6 @@
options XENDEBUG
options XENDEBUG_LOW
options XENDEBUG_NET
-options XENDEBUG_SYNC
options XENDEBUG_VBD
options XENNET_DEBUG
options XENNET_DEBUG_DUMP
diff -r a78f026502ce -r f2f23de83fd8 sys/arch/xen/include/xenpmap.h
--- a/sys/arch/xen/include/xenpmap.h Wed Mar 08 17:06:35 2017 +0000
+++ b/sys/arch/xen/include/xenpmap.h Wed Mar 08 18:00:49 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenpmap.h,v 1.38 2014/05/06 04:26:24 cherry Exp $ */
+/* $NetBSD: xenpmap.h,v 1.39 2017/03/08 18:00:49 maxv Exp $ */
/*
*
@@ -49,8 +49,6 @@
void xpq_queue_pin_table(paddr_t, int);
void xpq_queue_unpin_table(paddr_t);
int xpq_update_foreign(paddr_t, pt_entry_t, int);
-void xen_vcpu_mcast_invlpg(vaddr_t, vaddr_t, kcpuset_t *);
-void xen_vcpu_bcast_invlpg(vaddr_t, vaddr_t);
void xen_mcast_tlbflush(kcpuset_t *);
void xen_bcast_tlbflush(void);
void xen_mcast_invlpg(vaddr_t, kcpuset_t *);
diff -r a78f026502ce -r f2f23de83fd8 sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c Wed Mar 08 17:06:35 2017 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c Wed Mar 08 18:00:49 2017 +0000
@@ -1,4 +1,33 @@
-/* $NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $ */
+/* $NetBSD: x86_xpmap.c,v 1.72 2017/03/08 18:00:49 maxv Exp $ */
+
+/*
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/*
* Copyright (c) 2006 Mathieu Ropert <mro%adviseo.fr@localhost>
@@ -66,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.72 2017/03/08 18:00:49 maxv Exp $");
#include "opt_xen.h"
#include "opt_ddb.h"
@@ -87,7 +116,6 @@
#include <machine/isa_machdep.h>
#undef XENDEBUG
-/* #define XENDEBUG_SYNC */
#ifdef XENDEBUG
#define XENPRINTF(x) printf x
@@ -98,19 +126,24 @@
#define XENPRINTK2(x)
#endif
-volatile shared_info_t *HYPERVISOR_shared_info;
/* Xen requires the start_info struct to be page aligned */
union start_info_union start_info_union __aligned(PAGE_SIZE);
-unsigned long *xpmap_phys_to_machine_mapping;
-kmutex_t pte_lock;
+
+volatile shared_info_t *HYPERVISOR_shared_info __read_mostly;
+unsigned long *xpmap_phys_to_machine_mapping __read_mostly;
+kmutex_t pte_lock __cacheline_aligned;
vaddr_t xen_dummy_page;
-
pt_entry_t xpmap_pg_nx __read_mostly;
-void xen_failsafe_handler(void);
+#define XPQUEUE_SIZE 2048
+static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
+static int xpq_idx_array[MAXCPUS];
-#define HYPERVISOR_mmu_update_self(req, count, success_count) \
- HYPERVISOR_mmu_update((req), (count), (success_count), DOMID_SELF)
+#ifdef XENDEBUG
+void xpq_debug_dump(void);
+#endif
+
+void xen_failsafe_handler(void);
extern volatile struct xencons_interface *xencons_interface; /* XXX */
extern struct xenstore_domain_interface *xenstore_interface; /* XXX */
@@ -166,33 +199,17 @@
splx(s);
}
-#ifdef XENDEBUG
-void xpq_debug_dump(void);
-#endif
-
-#define XPQUEUE_SIZE 2048
-static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
-static int xpq_idx_array[MAXCPUS];
-
-#ifdef i386
-extern union descriptor tmpgdt[];
-#endif
-
void
xpq_flush_queue(void)
{
- int i, ok = 0, ret;
-
- mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
- int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
+ mmu_update_t *xpq_queue;
+ int i, ok = 0, ret, xpq_idx;
- XENPRINTK2(("flush queue %p entries %d\n", xpq_queue, xpq_idx));
- for (i = 0; i < xpq_idx; i++)
- XENPRINTK2(("%d: 0x%08" PRIx64 " 0x%08" PRIx64 "\n", i,
- xpq_queue[i].ptr, xpq_queue[i].val));
+ xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
+ xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
retry:
- ret = HYPERVISOR_mmu_update_self(xpq_queue, xpq_idx, &ok);
+ ret = HYPERVISOR_mmu_update(xpq_queue, xpq_idx, &ok, DOMID_SELF);
if (xpq_idx != 0 && ret < 0) {
struct cpu_info *ci;
@@ -242,45 +259,32 @@
void
xpq_queue_machphys_update(paddr_t ma, paddr_t pa)
{
-
mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
- XENPRINTK2(("xpq_queue_machphys_update ma=0x%" PRIx64 " pa=0x%" PRIx64
- "\n", (int64_t)ma, (int64_t)pa));
-
xpq_queue[xpq_idx].ptr = ma | MMU_MACHPHYS_UPDATE;
xpq_queue[xpq_idx].val = pa >> PAGE_SHIFT;
xpq_increment_idx();
-#ifdef XENDEBUG_SYNC
- xpq_flush_queue();
-#endif
}
void
xpq_queue_pte_update(paddr_t ptr, pt_entry_t val)
{
-
mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
- KASSERT((ptr & 3) == 0);
- xpq_queue[xpq_idx].ptr = (paddr_t)ptr | MMU_NORMAL_PT_UPDATE;
+ xpq_queue[xpq_idx].ptr = ptr | MMU_NORMAL_PT_UPDATE;
xpq_queue[xpq_idx].val = val;
xpq_increment_idx();
-#ifdef XENDEBUG_SYNC
- xpq_flush_queue();
-#endif
}
void
xpq_queue_pt_switch(paddr_t pa)
{
struct mmuext_op op;
+
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_pt_switch: 0x%" PRIx64 " 0x%" PRIx64 "\n",
- (int64_t)pa, (int64_t)pa));
op.cmd = MMUEXT_NEW_BASEPTR;
op.arg1.mfn = pa >> PAGE_SHIFT;
if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
@@ -294,12 +298,8 @@
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_pin_l%d_table: %#" PRIxPADDR "\n",
- lvl + 1, pa));
-
op.arg1.mfn = pa >> PAGE_SHIFT;
op.cmd = lvl;
-
if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
panic("xpq_queue_pin_table");
}
@@ -311,7 +311,6 @@
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_unpin_table: %#" PRIxPADDR "\n", pa));
op.arg1.mfn = pa >> PAGE_SHIFT;
op.cmd = MMUEXT_UNPIN_TABLE;
if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
@@ -325,7 +324,6 @@
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_set_ldt\n"));
KASSERT(va == (va & ~PAGE_MASK));
op.cmd = MMUEXT_SET_LDT;
op.arg1.linear_addr = va;
@@ -341,7 +339,6 @@
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_tlb_flush\n"));
op.cmd = MMUEXT_TLB_FLUSH_LOCAL;
if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
panic("xpq_queue_tlb_flush");
@@ -354,7 +351,6 @@
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_flush_cache\n"));
asm("wbinvd":::"memory");
splx(s); /* XXX: removeme */
}
@@ -363,9 +359,9 @@
xpq_queue_invlpg(vaddr_t va)
{
struct mmuext_op op;
+
xpq_flush_queue();
- XENPRINTK2(("xpq_queue_invlpg %#" PRIxVADDR "\n", va));
op.cmd = MMUEXT_INVLPG_LOCAL;
op.arg1.linear_addr = (va & ~PAGE_MASK);
if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
Home |
Main Index |
Thread Index |
Old Index