Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen remove unnecessary locking overhead for UP
details: https://anonhg.NetBSD.org/src/rev/9fdd43b67a5a
branches: trunk
changeset: 768260:9fdd43b67a5a
user: cherry <cherry%NetBSD.org@localhost>
date: Sat Aug 13 11:41:57 2011 +0000
description:
remove unnecessary locking overhead for UP
diffstat:
sys/arch/xen/include/xenpmap.h | 10 ++++++++-
sys/arch/xen/x86/x86_xpmap.c | 47 +++++++++++++++++++++++++----------------
2 files changed, 37 insertions(+), 20 deletions(-)
diffs (219 lines):
diff -r dd89629f5e0d -r 9fdd43b67a5a sys/arch/xen/include/xenpmap.h
--- a/sys/arch/xen/include/xenpmap.h Sat Aug 13 11:10:31 2011 +0000
+++ b/sys/arch/xen/include/xenpmap.h Sat Aug 13 11:41:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenpmap.h,v 1.28 2011/08/10 09:50:37 cherry Exp $ */
+/* $NetBSD: xenpmap.h,v 1.29 2011/08/13 11:41:57 cherry Exp $ */
/*
*
@@ -36,8 +36,16 @@
#define INVALID_P2M_ENTRY (~0UL)
+#ifdef MULTIPROCESSOR
void xpq_queue_lock(void);
void xpq_queue_unlock(void);
+bool xpq_queue_locked(void);
+#else /* MULTIPROCESSOR */
+#define xpq_queue_lock() do {} while(0) /* nothing */
+#define xpq_queue_unlock() do {} while(0) /* nothing */
+#define xpq_queue_locked() (true) /* Always true for UP */
+#endif /* MULTIPROCESSOR */
+
void xpq_queue_machphys_update(paddr_t, paddr_t);
void xpq_queue_invlpg(vaddr_t);
void xpq_queue_pte_update(paddr_t, pt_entry_t);
diff -r dd89629f5e0d -r 9fdd43b67a5a sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c Sat Aug 13 11:10:31 2011 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c Sat Aug 13 11:41:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_xpmap.c,v 1.29 2011/08/10 09:50:37 cherry Exp $ */
+/* $NetBSD: x86_xpmap.c,v 1.30 2011/08/13 11:41:57 cherry 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.29 2011/08/10 09:50:37 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.30 2011/08/13 11:41:57 cherry Exp $");
#include "opt_xen.h"
#include "opt_ddb.h"
@@ -166,6 +166,8 @@
#define XPQUEUE_SIZE 2048
static mmu_update_t xpq_queue[XPQUEUE_SIZE];
static int xpq_idx = 0;
+
+#ifdef MULTIPROCESSOR
static struct simplelock xpq_lock = SIMPLELOCK_INITIALIZER;
void
@@ -180,13 +182,20 @@
simple_unlock(&xpq_lock);
}
+bool
+xpq_queue_locked(void)
+{
+ return xpq_queue_locked();
+}
+#endif /* MULTIPROCESSOR */
+
/* Must be called with xpq_lock held */
void
xpq_flush_queue(void)
{
int i, ok, ret;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
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,
@@ -210,7 +219,7 @@
xpq_increment_idx(void)
{
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_idx++;
if (__predict_false(xpq_idx == XPQUEUE_SIZE))
xpq_flush_queue();
@@ -221,7 +230,7 @@
{
XENPRINTK2(("xpq_queue_machphys_update ma=0x%" PRIx64 " pa=0x%" PRIx64
"\n", (int64_t)ma, (int64_t)pa));
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_queue[xpq_idx].ptr = ma | MMU_MACHPHYS_UPDATE;
xpq_queue[xpq_idx].val = (pa - XPMAP_OFFSET) >> PAGE_SHIFT;
xpq_increment_idx();
@@ -235,7 +244,7 @@
{
KASSERT((ptr & 3) == 0);
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_queue[xpq_idx].ptr = (paddr_t)ptr | MMU_NORMAL_PT_UPDATE;
xpq_queue[xpq_idx].val = val;
xpq_increment_idx();
@@ -248,7 +257,7 @@
xpq_queue_pt_switch(paddr_t pa)
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_pt_switch: 0x%" PRIx64 " 0x%" PRIx64 "\n",
@@ -264,7 +273,7 @@
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_pin_l%d_table: %#" PRIxPADDR "\n",
@@ -282,7 +291,7 @@
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_unpin_table: %#" PRIxPADDR "\n", pa));
@@ -297,7 +306,7 @@
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_set_ldt\n"));
@@ -314,7 +323,7 @@
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_tlb_flush\n"));
@@ -345,7 +354,7 @@
xpq_queue_invlpg(vaddr_t va)
{
struct mmuext_op op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
XENPRINTK2(("xpq_queue_invlpg %#" PRIxVADDR "\n", va));
@@ -360,7 +369,7 @@
{
mmuext_op_t op;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
/* Flush pending page updates */
xpq_flush_queue();
@@ -382,7 +391,7 @@
mmuext_op_t op;
/* Flush pending page updates */
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
op.cmd = MMUEXT_INVLPG_ALL;
@@ -402,7 +411,7 @@
mmuext_op_t op;
/* Flush pending page updates */
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
op.cmd = MMUEXT_TLB_FLUSH_MULTI;
@@ -422,7 +431,7 @@
mmuext_op_t op;
/* Flush pending page updates */
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
op.cmd = MMUEXT_TLB_FLUSH_ALL;
@@ -441,7 +450,7 @@
KASSERT(eva > sva);
/* Flush pending page updates */
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
/* Align to nearest page boundary */
@@ -462,7 +471,7 @@
KASSERT(eva > sva);
/* Flush pending page updates */
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
/* Align to nearest page boundary */
@@ -482,7 +491,7 @@
mmu_update_t op;
int ok;
- KASSERT(simple_lock_held(&xpq_lock));
+ KASSERT(xpq_queue_locked());
xpq_flush_queue();
op.ptr = ptr;
Home |
Main Index |
Thread Index |
Old Index