Rip out the rwlock spl emulation code. It never did anything useful

except keep my feet warm by consuming an insane amount of cpu
cycles -- in rump our current "cpu" context is never interrupted
& we have MULTIPROCESSOR.

(itch i'm scratching: it made the networking stack 10-20% slower.
this is one of the places where fast code actually matters)
This commit is contained in:
pooka 2009-02-06 20:01:41 +00:00
parent 957effbd58
commit b90ea1cecf
8 changed files with 20 additions and 144 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.15 2009/01/24 12:34:04 he Exp $ */
/* $NetBSD: intr.h,v 1.16 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -49,17 +49,14 @@ ipl_cookie_t makeiplcookie(ipl_t ipl)
#endif /* !_LOCORE */
int rump_splfoo(void);
void rump_splx(int);
#define spllower(x) ((void)0)
#define spllower(x) ((void)x)
#define splraise(x) 0
#define splsoftnet() rump_splfoo()
#define splsoftclock() rump_splfoo()
#define splhigh() rump_splfoo()
#define splsched() rump_splfoo()
#define splvm() rump_splfoo()
#define splx(x) rump_splx(x)
#define splsoftnet() 0
#define splsoftclock() 0
#define splhigh() 0
#define splsched() 0
#define splvm() 0
#define splx(x) ((void)x)
#define spl0() ((void)0)
#define IPL_NONE 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump.h,v 1.6 2009/01/08 03:27:10 pooka Exp $ */
/* $NetBSD: rump.h,v 1.7 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -136,11 +136,6 @@ void rump_clear_curlwp(void);
void rump_rcvp_set(struct vnode *, struct vnode *);
struct vnode *rump_cdir_get(void);
void rump_intr_enter(void);
void rump_intr_exit(void);
int rump_splfoo(void);
void rump_splx(int);
/* I picked the wrong header to stop sniffin' glue */
int rump_syspuffs_glueinit(int, int *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser.h,v 1.13 2009/01/27 09:14:01 pooka Exp $ */
/* $NetBSD: rumpuser.h,v 1.14 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -145,15 +145,6 @@ extern struct rumpuser_cv rumpuser_aio_cv;
extern struct rumpuser_aio rumpuser_aios[N_AIOS];
extern int rumpuser_aio_head, rumpuser_aio_tail;
extern struct rumpuser_rw rumpspl;
#define RUMPUSER_IPL_SPLFOO 1
#define RUMPUSER_IPL_INTR (-1)
void rumpuser_set_ipl(int);
int rumpuser_whatis_ipl(void);
void rumpuser_clear_ipl(int);
/* rumpuser_net */
int rumpuser_net_socket(int, int, int, int *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpspl.c,v 1.1 2009/01/01 16:50:30 pooka Exp $ */
/* $NetBSD: rumpspl.c,v 1.2 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rumpspl.c,v 1.1 2009/01/01 16:50:30 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rumpspl.c,v 1.2 2009/02/06 20:01:41 pooka Exp $");
#include <sys/param.h>
@ -41,12 +41,11 @@ void
spllower(int s)
{
rump_splx(s);
}
int
splraise(int s)
{
return rump_splfoo();
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ltsleep.c,v 1.9 2008/12/18 00:24:12 pooka Exp $ */
/* $NetBSD: ltsleep.c,v 1.10 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.9 2008/12/18 00:24:12 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.10 2009/02/06 20:01:41 pooka Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -56,7 +56,6 @@ ltsleep(wchan_t ident, pri_t prio, const char *wmesg, int timo,
volatile struct simplelock *slock)
{
struct ltsleeper lts;
int iplrecurse;
if (__predict_false(slock))
panic("simplelock not supported by rump, convert code");
@ -67,19 +66,9 @@ ltsleep(wchan_t ident, pri_t prio, const char *wmesg, int timo,
mutex_enter(&sleepermtx);
LIST_INSERT_HEAD(&sleepers, &lts, entries);
/* release spl */
iplrecurse = rumpuser_whatis_ipl();
while (iplrecurse--)
rumpuser_rw_exit(&rumpspl);
/* protected by sleepermtx */
cv_wait(&lts.cv, &sleepermtx);
/* retake ipl */
iplrecurse = rumpuser_whatis_ipl();
while (iplrecurse--)
rumpuser_rw_enter(&rumpspl, 0);
LIST_REMOVE(&lts, entries);
mutex_exit(&sleepermtx);
@ -93,7 +82,6 @@ mtsleep(wchan_t ident, pri_t prio, const char *wmesg, int timo,
kmutex_t *lock)
{
struct ltsleeper lts;
int iplrecurse;
lts.id = ident;
cv_init(&lts.cv, NULL);
@ -101,20 +89,10 @@ mtsleep(wchan_t ident, pri_t prio, const char *wmesg, int timo,
mutex_enter(&sleepermtx);
LIST_INSERT_HEAD(&sleepers, &lts, entries);
/* release spl */
iplrecurse = rumpuser_whatis_ipl();
while (iplrecurse--)
rumpuser_rw_exit(&rumpspl);
/* protected by sleepermtx */
mutex_exit(lock);
cv_wait(&lts.cv, &sleepermtx);
/* retake ipl */
iplrecurse = rumpuser_whatis_ipl();
while (iplrecurse--)
rumpuser_rw_enter(&rumpspl, 0);
LIST_REMOVE(&lts, entries);
mutex_exit(&sleepermtx);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump.c,v 1.92 2009/02/06 19:49:13 pooka Exp $ */
/* $NetBSD: rump.c,v 1.93 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.92 2009/02/06 19:49:13 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.93 2009/02/06 20:01:41 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -350,44 +350,6 @@ rump_get_curlwp()
return l;
}
int
rump_splfoo()
{
if (rumpuser_whatis_ipl() != RUMPUSER_IPL_INTR) {
rumpuser_rw_enter(&rumpspl, 0);
rumpuser_set_ipl(RUMPUSER_IPL_SPLFOO);
}
return 0;
}
void
rump_intr_enter(void)
{
rumpuser_set_ipl(RUMPUSER_IPL_INTR);
rumpuser_rw_enter(&rumpspl, 1);
}
void
rump_intr_exit(void)
{
rumpuser_rw_exit(&rumpspl);
rumpuser_clear_ipl(RUMPUSER_IPL_INTR);
}
void
rump_splx(int dummy)
{
if (rumpuser_whatis_ipl() != RUMPUSER_IPL_INTR) {
rumpuser_clear_ipl(RUMPUSER_IPL_SPLFOO);
rumpuser_rw_exit(&rumpspl);
}
}
kauth_cred_t
rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser_pth.c,v 1.26 2009/01/27 09:14:01 pooka Exp $ */
/* $NetBSD: rumpuser_pth.c,v 1.27 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: rumpuser_pth.c,v 1.26 2009/01/27 09:14:01 pooka Exp $");
__RCSID("$NetBSD: rumpuser_pth.c,v 1.27 2009/02/06 20:01:41 pooka Exp $");
#endif /* !lint */
#ifdef __linux__
@ -52,7 +52,6 @@ __RCSID("$NetBSD: rumpuser_pth.c,v 1.26 2009/01/27 09:14:01 pooka Exp $");
#include "rumpuser_int.h"
static pthread_key_t curlwpkey;
static pthread_key_t isintr;
#define NOFAIL(a) do {if (!(a)) abort();} while (/*CONSTCOND*/0)
#define NOFAIL_ERRNO(a) \
@ -120,8 +119,6 @@ struct rumpuser_cv rumpuser_aio_cv;
int rumpuser_aio_head, rumpuser_aio_tail;
struct rumpuser_aio rumpuser_aios[N_AIOS];
struct rumpuser_rw rumpspl;
kernel_lockfn rumpuser__klock;
kernel_unlockfn rumpuser__kunlock;
int rumpuser__wantthreads;
@ -163,11 +160,8 @@ rumpuser_thrinit(kernel_lockfn lockfn, kernel_unlockfn unlockfn, int threads)
pthread_mutex_init(&rumpuser_aio_mtx.pthmtx, NULL);
pthread_cond_init(&rumpuser_aio_cv.pthcv, NULL);
pthread_rwlock_init(&rumpspl.pthrw, NULL);
pthread_spin_init(&rumpspl.spin, PTHREAD_PROCESS_SHARED);
pthread_key_create(&curlwpkey, NULL);
pthread_key_create(&isintr, NULL);
rumpuser__klock = lockfn;
rumpuser__kunlock = unlockfn;
@ -483,41 +477,3 @@ rumpuser_get_curlwp()
return pthread_getspecific(curlwpkey);
}
/*
* I am the interrupt
*/
void
rumpuser_set_ipl(int what)
{
int cur;
if (what == RUMPUSER_IPL_INTR) {
pthread_setspecific(isintr, (void *)RUMPUSER_IPL_INTR);
} else {
cur = (int)(intptr_t)pthread_getspecific(isintr);
pthread_setspecific(isintr, (void *)(intptr_t)(cur+1));
}
}
int
rumpuser_whatis_ipl()
{
return (int)(intptr_t)pthread_getspecific(isintr);
}
void
rumpuser_clear_ipl(int what)
{
int cur;
if (what == RUMPUSER_IPL_INTR)
cur = 1;
else
cur = (int)(intptr_t)pthread_getspecific(isintr);
cur--;
pthread_setspecific(isintr, (void *)(intptr_t)cur);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_vfs.c,v 1.11 2009/01/13 11:40:55 pooka Exp $ */
/* $NetBSD: rump_vfs.c,v 1.12 2009/02/06 20:01:41 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@ -527,9 +527,7 @@ rump_biodone(void *arg, size_t count, int error)
KASSERT(bp->b_resid >= 0);
bp->b_error = error;
rump_intr_enter();
biodone(bp);
rump_intr_exit();
}
static void