remove unnecessary locking overhead for UP
This commit is contained in:
parent
86658a2f92
commit
787e5fb097
|
@ -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)
|
#define INVALID_P2M_ENTRY (~0UL)
|
||||||
|
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
void xpq_queue_lock(void);
|
void xpq_queue_lock(void);
|
||||||
void xpq_queue_unlock(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_machphys_update(paddr_t, paddr_t);
|
||||||
void xpq_queue_invlpg(vaddr_t);
|
void xpq_queue_invlpg(vaddr_t);
|
||||||
void xpq_queue_pte_update(paddr_t, pt_entry_t);
|
void xpq_queue_pte_update(paddr_t, pt_entry_t);
|
||||||
|
|
|
@ -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>
|
* Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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_xen.h"
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
|
@ -166,6 +166,8 @@ void xpq_debug_dump(void);
|
||||||
#define XPQUEUE_SIZE 2048
|
#define XPQUEUE_SIZE 2048
|
||||||
static mmu_update_t xpq_queue[XPQUEUE_SIZE];
|
static mmu_update_t xpq_queue[XPQUEUE_SIZE];
|
||||||
static int xpq_idx = 0;
|
static int xpq_idx = 0;
|
||||||
|
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
static struct simplelock xpq_lock = SIMPLELOCK_INITIALIZER;
|
static struct simplelock xpq_lock = SIMPLELOCK_INITIALIZER;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -180,13 +182,20 @@ xpq_queue_unlock(void)
|
||||||
simple_unlock(&xpq_lock);
|
simple_unlock(&xpq_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
xpq_queue_locked(void)
|
||||||
|
{
|
||||||
|
return xpq_queue_locked();
|
||||||
|
}
|
||||||
|
#endif /* MULTIPROCESSOR */
|
||||||
|
|
||||||
/* Must be called with xpq_lock held */
|
/* Must be called with xpq_lock held */
|
||||||
void
|
void
|
||||||
xpq_flush_queue(void)
|
xpq_flush_queue(void)
|
||||||
{
|
{
|
||||||
int i, ok, ret;
|
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));
|
XENPRINTK2(("flush queue %p entries %d\n", xpq_queue, xpq_idx));
|
||||||
for (i = 0; i < xpq_idx; i++)
|
for (i = 0; i < xpq_idx; i++)
|
||||||
XENPRINTK2(("%d: 0x%08" PRIx64 " 0x%08" PRIx64 "\n", i,
|
XENPRINTK2(("%d: 0x%08" PRIx64 " 0x%08" PRIx64 "\n", i,
|
||||||
|
@ -210,7 +219,7 @@ static inline void
|
||||||
xpq_increment_idx(void)
|
xpq_increment_idx(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_idx++;
|
xpq_idx++;
|
||||||
if (__predict_false(xpq_idx == XPQUEUE_SIZE))
|
if (__predict_false(xpq_idx == XPQUEUE_SIZE))
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
@ -221,7 +230,7 @@ xpq_queue_machphys_update(paddr_t ma, paddr_t pa)
|
||||||
{
|
{
|
||||||
XENPRINTK2(("xpq_queue_machphys_update ma=0x%" PRIx64 " pa=0x%" PRIx64
|
XENPRINTK2(("xpq_queue_machphys_update ma=0x%" PRIx64 " pa=0x%" PRIx64
|
||||||
"\n", (int64_t)ma, (int64_t)pa));
|
"\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].ptr = ma | MMU_MACHPHYS_UPDATE;
|
||||||
xpq_queue[xpq_idx].val = (pa - XPMAP_OFFSET) >> PAGE_SHIFT;
|
xpq_queue[xpq_idx].val = (pa - XPMAP_OFFSET) >> PAGE_SHIFT;
|
||||||
xpq_increment_idx();
|
xpq_increment_idx();
|
||||||
|
@ -235,7 +244,7 @@ xpq_queue_pte_update(paddr_t ptr, pt_entry_t val)
|
||||||
{
|
{
|
||||||
|
|
||||||
KASSERT((ptr & 3) == 0);
|
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].ptr = (paddr_t)ptr | MMU_NORMAL_PT_UPDATE;
|
||||||
xpq_queue[xpq_idx].val = val;
|
xpq_queue[xpq_idx].val = val;
|
||||||
xpq_increment_idx();
|
xpq_increment_idx();
|
||||||
|
@ -248,7 +257,7 @@ void
|
||||||
xpq_queue_pt_switch(paddr_t pa)
|
xpq_queue_pt_switch(paddr_t pa)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_pt_switch: 0x%" PRIx64 " 0x%" PRIx64 "\n",
|
XENPRINTK2(("xpq_queue_pt_switch: 0x%" PRIx64 " 0x%" PRIx64 "\n",
|
||||||
|
@ -264,7 +273,7 @@ xpq_queue_pin_table(paddr_t pa, int lvl)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_pin_l%d_table: %#" PRIxPADDR "\n",
|
XENPRINTK2(("xpq_queue_pin_l%d_table: %#" PRIxPADDR "\n",
|
||||||
|
@ -282,7 +291,7 @@ xpq_queue_unpin_table(paddr_t pa)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_unpin_table: %#" PRIxPADDR "\n", pa));
|
XENPRINTK2(("xpq_queue_unpin_table: %#" PRIxPADDR "\n", pa));
|
||||||
|
@ -297,7 +306,7 @@ xpq_queue_set_ldt(vaddr_t va, uint32_t entries)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_set_ldt\n"));
|
XENPRINTK2(("xpq_queue_set_ldt\n"));
|
||||||
|
@ -314,7 +323,7 @@ xpq_queue_tlb_flush(void)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_tlb_flush\n"));
|
XENPRINTK2(("xpq_queue_tlb_flush\n"));
|
||||||
|
@ -345,7 +354,7 @@ void
|
||||||
xpq_queue_invlpg(vaddr_t va)
|
xpq_queue_invlpg(vaddr_t va)
|
||||||
{
|
{
|
||||||
struct mmuext_op op;
|
struct mmuext_op op;
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
XENPRINTK2(("xpq_queue_invlpg %#" PRIxVADDR "\n", va));
|
XENPRINTK2(("xpq_queue_invlpg %#" PRIxVADDR "\n", va));
|
||||||
|
@ -360,7 +369,7 @@ xen_mcast_invlpg(vaddr_t va, uint32_t cpumask)
|
||||||
{
|
{
|
||||||
mmuext_op_t op;
|
mmuext_op_t op;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
@ -382,7 +391,7 @@ xen_bcast_invlpg(vaddr_t va)
|
||||||
mmuext_op_t op;
|
mmuext_op_t op;
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
op.cmd = MMUEXT_INVLPG_ALL;
|
op.cmd = MMUEXT_INVLPG_ALL;
|
||||||
|
@ -402,7 +411,7 @@ xen_mcast_tlbflush(uint32_t cpumask)
|
||||||
mmuext_op_t op;
|
mmuext_op_t op;
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
op.cmd = MMUEXT_TLB_FLUSH_MULTI;
|
op.cmd = MMUEXT_TLB_FLUSH_MULTI;
|
||||||
|
@ -422,7 +431,7 @@ xen_bcast_tlbflush(void)
|
||||||
mmuext_op_t op;
|
mmuext_op_t op;
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
op.cmd = MMUEXT_TLB_FLUSH_ALL;
|
op.cmd = MMUEXT_TLB_FLUSH_ALL;
|
||||||
|
@ -441,7 +450,7 @@ xen_vcpu_mcast_invlpg(vaddr_t sva, vaddr_t eva, uint32_t cpumask)
|
||||||
KASSERT(eva > sva);
|
KASSERT(eva > sva);
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
/* Align to nearest page boundary */
|
/* Align to nearest page boundary */
|
||||||
|
@ -462,7 +471,7 @@ xen_vcpu_bcast_invlpg(vaddr_t sva, vaddr_t eva)
|
||||||
KASSERT(eva > sva);
|
KASSERT(eva > sva);
|
||||||
|
|
||||||
/* Flush pending page updates */
|
/* Flush pending page updates */
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
/* Align to nearest page boundary */
|
/* Align to nearest page boundary */
|
||||||
|
@ -482,7 +491,7 @@ xpq_update_foreign(paddr_t ptr, pt_entry_t val, int dom)
|
||||||
mmu_update_t op;
|
mmu_update_t op;
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
KASSERT(simple_lock_held(&xpq_lock));
|
KASSERT(xpq_queue_locked());
|
||||||
xpq_flush_queue();
|
xpq_flush_queue();
|
||||||
|
|
||||||
op.ptr = ptr;
|
op.ptr = ptr;
|
||||||
|
|
Loading…
Reference in New Issue