Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src roll mutex init hypercalls into one (one of them already too...
details: https://anonhg.NetBSD.org/src/rev/d1145ab2cc37
branches: trunk
changeset: 786368:d1145ab2cc37
user: pooka <pooka%NetBSD.org@localhost>
date: Sat Apr 27 16:32:56 2013 +0000
description:
roll mutex init hypercalls into one (one of them already took a flag anyway)
diffstat:
lib/librumpuser/rumpuser_pth.c | 30 +++++++++++-------------------
lib/librumpuser/rumpuser_pth_dummy.c | 13 +++----------
sys/rump/include/rump/rumpuser.h | 7 ++++---
sys/rump/librump/rumpkern/intr.c | 6 +++---
sys/rump/librump/rumpkern/locks.c | 13 ++++++++-----
sys/rump/librump/rumpkern/ltsleep.c | 6 +++---
sys/rump/librump/rumpkern/rump.c | 6 +++---
sys/rump/librump/rumpkern/scheduler.c | 8 ++++----
sys/rump/librump/rumpkern/threads.c | 6 +++---
9 files changed, 42 insertions(+), 53 deletions(-)
diffs (truncated from 343 to 300 lines):
diff -r ed298835b393 -r d1145ab2cc37 lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c Sat Apr 27 16:05:54 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.14 2013/04/27 14:59:08 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.15 2013/04/27 16:32:58 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.14 2013/04/27 14:59:08 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.15 2013/04/27 16:32:58 pooka Exp $");
#endif /* !lint */
#include <assert.h>
@@ -58,8 +58,6 @@
} \
} while (/*CONSTCOND*/0)
-#define MTX_KMUTEX 0x1
-#define MTX_ISSPIN 0x2
struct rumpuser_mtx {
pthread_mutex_t pthmtx;
struct lwp *owner;
@@ -252,7 +250,7 @@
}
void
-rumpuser_mutex_init(struct rumpuser_mtx **mtx)
+rumpuser_mutex_init(struct rumpuser_mtx **mtx, int flags)
{
pthread_mutexattr_t att;
@@ -264,22 +262,15 @@
pthread_mutexattr_destroy(&att);
(*mtx)->owner = NULL;
- (*mtx)->flags = MTX_ISSPIN;
-}
-
-void
-rumpuser_mutex_init_kmutex(struct rumpuser_mtx **mtx, int isspin)
-{
-
- rumpuser_mutex_init(mtx);
- (*mtx)->flags = MTX_KMUTEX | (isspin ? MTX_ISSPIN : 0);
+ assert(flags != 0);
+ (*mtx)->flags = flags;
}
static void
mtxenter(struct rumpuser_mtx *mtx)
{
- if (!(mtx->flags & MTX_KMUTEX))
+ if (!(mtx->flags & RUMPUSER_MTX_KMUTEX))
return;
assert(mtx->owner == NULL);
@@ -290,7 +281,7 @@
mtxexit(struct rumpuser_mtx *mtx)
{
- if (!(mtx->flags & MTX_KMUTEX))
+ if (!(mtx->flags & RUMPUSER_MTX_KMUTEX))
return;
assert(mtx->owner != NULL);
@@ -301,11 +292,12 @@
rumpuser_mutex_enter(struct rumpuser_mtx *mtx)
{
- if (mtx->flags & MTX_ISSPIN) {
+ if (mtx->flags & RUMPUSER_MTX_SPIN) {
rumpuser_mutex_enter_nowrap(mtx);
return;
}
+ assert(mtx->flags & RUMPUSER_MTX_KMUTEX);
if (pthread_mutex_trylock(&mtx->pthmtx) != 0)
KLOCK_WRAP(NOFAIL_ERRNO(pthread_mutex_lock(&mtx->pthmtx)));
mtxenter(mtx);
@@ -315,7 +307,7 @@
rumpuser_mutex_enter_nowrap(struct rumpuser_mtx *mtx)
{
- assert(mtx->flags & MTX_ISSPIN);
+ assert(mtx->flags & RUMPUSER_MTX_SPIN);
NOFAIL_ERRNO(pthread_mutex_lock(&mtx->pthmtx));
mtxenter(mtx);
}
@@ -353,7 +345,7 @@
rumpuser_mutex_owner(struct rumpuser_mtx *mtx)
{
- if (__predict_false(!(mtx->flags & MTX_KMUTEX))) {
+ if (__predict_false(!(mtx->flags & RUMPUSER_MTX_KMUTEX))) {
printf("panic: rumpuser_mutex_held unsupported on non-kmtx\n");
abort();
}
diff -r ed298835b393 -r d1145ab2cc37 lib/librumpuser/rumpuser_pth_dummy.c
--- a/lib/librumpuser/rumpuser_pth_dummy.c Sat Apr 27 16:05:54 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth_dummy.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth_dummy.c,v 1.9 2013/04/27 14:59:08 pooka Exp $ */
+/* $NetBSD: rumpuser_pth_dummy.c,v 1.10 2013/04/27 16:32:58 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.9 2013/04/27 14:59:08 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.10 2013/04/27 16:32:58 pooka Exp $");
#endif /* !lint */
#include <sys/time.h>
@@ -99,14 +99,7 @@
}
void
-rumpuser_mutex_init(struct rumpuser_mtx **mtx)
-{
-
- *mtx = calloc(1, sizeof(struct rumpuser_mtx));
-}
-
-void
-rumpuser_mutex_init_kmutex(struct rumpuser_mtx **mtx, int isspin)
+rumpuser_mutex_init(struct rumpuser_mtx **mtx, int flgas)
{
*mtx = calloc(1, sizeof(struct rumpuser_mtx));
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/include/rump/rumpuser.h Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.83 2013/04/27 16:05:54 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.84 2013/04/27 16:32:56 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -135,8 +135,9 @@
struct lwp *rumpuser_get_curlwp(void);
struct rumpuser_mtx;
-void rumpuser_mutex_init(struct rumpuser_mtx **);
-void rumpuser_mutex_init_kmutex(struct rumpuser_mtx **, int);
+#define RUMPUSER_MTX_SPIN 0x01
+#define RUMPUSER_MTX_KMUTEX 0x02
+void rumpuser_mutex_init(struct rumpuser_mtx **, int);
void rumpuser_mutex_enter(struct rumpuser_mtx *);
void rumpuser_mutex_enter_nowrap(struct rumpuser_mtx *);
int rumpuser_mutex_tryenter(struct rumpuser_mtx *);
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/librump/rumpkern/intr.c
--- a/sys/rump/librump/rumpkern/intr.c Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/librump/rumpkern/intr.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.36 2011/03/21 16:41:08 pooka Exp $ */
+/* $NetBSD: intr.c,v 1.37 2013/04/27 16:32:57 pooka Exp $ */
/*
* Copyright (c) 2008-2010 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.36 2011/03/21 16:41:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.37 2013/04/27 16:32:57 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -117,7 +117,7 @@
/* XXX: dummies */
rumpuser_cv_init(&clockcv);
- rumpuser_mutex_init(&clockmtx);
+ rumpuser_mutex_init(&clockmtx, RUMPUSER_MTX_SPIN);
rumpuser_mutex_enter_nowrap(clockmtx);
for (;;) {
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locks.c,v 1.56 2013/04/27 13:59:46 pooka Exp $ */
+/* $NetBSD: locks.c,v 1.57 2013/04/27 16:32:57 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.56 2013/04/27 13:59:46 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.57 2013/04/27 16:32:57 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -90,8 +90,11 @@
void
mutex_init(kmutex_t *mtx, kmutex_type_t type, int ipl)
{
+ int ruflags = RUMPUSER_MTX_KMUTEX;
int isspin;
+ CTASSERT(sizeof(kmutex_t) >= sizeof(void *));
+
/*
* Try to figure out if the caller wanted a spin mutex or
* not with this easy set of conditionals. The difference
@@ -110,9 +113,9 @@
isspin = 1;
}
- CTASSERT(sizeof(kmutex_t) >= sizeof(void *));
-
- rumpuser_mutex_init_kmutex((struct rumpuser_mtx **)mtx, isspin);
+ if (isspin)
+ ruflags |= RUMPUSER_MTX_SPIN;
+ rumpuser_mutex_init((struct rumpuser_mtx **)mtx, ruflags);
ALLOCK(mtx, &mutex_lockops);
}
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/librump/rumpkern/ltsleep.c
--- a/sys/rump/librump/rumpkern/ltsleep.c Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/librump/rumpkern/ltsleep.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ltsleep.c,v 1.29 2012/01/28 12:22:33 rmind Exp $ */
+/* $NetBSD: ltsleep.c,v 1.30 2013/04/27 16:32:57 pooka Exp $ */
/*
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.29 2012/01/28 12:22:33 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.30 2013/04/27 16:32:57 pooka Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -174,5 +174,5 @@
rump_tsleep_init()
{
- rumpuser_mutex_init(&qlock);
+ rumpuser_mutex_init(&qlock, RUMPUSER_MTX_SPIN);
}
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.260 2013/04/27 16:02:56 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.261 2013/04/27 16:32:57 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.260 2013/04/27 16:02:56 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.261 2013/04/27 16:32:57 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -291,7 +291,7 @@
l->l_fd = &filedesc0;
rumpuser_set_curlwp(l);
- rumpuser_mutex_init(&rump_giantlock);
+ rumpuser_mutex_init(&rump_giantlock, RUMPUSER_MTX_SPIN);
ksyms_init();
uvm_init();
evcnt_init();
diff -r ed298835b393 -r d1145ab2cc37 sys/rump/librump/rumpkern/scheduler.c
--- a/sys/rump/librump/rumpkern/scheduler.c Sat Apr 27 16:05:54 2013 +0000
+++ b/sys/rump/librump/rumpkern/scheduler.c Sat Apr 27 16:32:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scheduler.c,v 1.30 2012/11/13 20:10:02 pooka Exp $ */
+/* $NetBSD: scheduler.c,v 1.31 2013/04/27 16:32:57 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.30 2012/11/13 20:10:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.31 2013/04/27 16:32:57 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -158,7 +158,7 @@
struct cpu_info *ci;
Home |
Main Index |
Thread Index |
Old Index