Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src * integrate rumpuser_getversion() with the hypervisor initia...
details: https://anonhg.NetBSD.org/src/rev/5f692773c4ae
branches: trunk
changeset: 786360:5f692773c4ae
user: pooka <pooka%NetBSD.org@localhost>
date: Sat Apr 27 14:59:08 2013 +0000
description:
* integrate rumpuser_getversion() with the hypervisor initialization
* rename some identifiers to better match reality
diffstat:
lib/librumpuser/rumpuser.c | 38 ++++++++++++++++++--
lib/librumpuser/rumpuser_component.c | 8 ++--
lib/librumpuser/rumpuser_int.h | 17 ++++----
lib/librumpuser/rumpuser_pth.c | 67 +++++++++--------------------------
lib/librumpuser/rumpuser_pth_dummy.c | 13 ++----
lib/librumpuser/rumpuser_sp.c | 20 +++++-----
sys/rump/include/rump/rumpuser.h | 10 ++---
sys/rump/librump/rumpkern/rump.c | 25 ++++++------
8 files changed, 94 insertions(+), 104 deletions(-)
diffs (truncated from 493 to 300 lines):
diff -r 87cb176b54f5 -r 5f692773c4ae lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Sat Apr 27 14:02:17 2013 +0000
+++ b/lib/librumpuser/rumpuser.c Sat Apr 27 14:59:08 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.c,v 1.29 2013/03/18 21:00:52 pooka Exp $ */
+/* $NetBSD: rumpuser.c,v 1.30 2013/04/27 14:59:08 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.c,v 1.29 2013/03/18 21:00:52 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.30 2013/04/27 14:59:08 pooka Exp $");
#endif /* !lint */
#include <sys/ioctl.h>
@@ -66,11 +66,41 @@
#include "rumpuser_int.h"
+rump_unschedulefn rumpuser__unschedule;
+rump_reschedulefn rumpuser__reschedule;
+
int
-rumpuser_getversion(void)
+rumpuser_init(int version,
+ rump_reschedulefn rumpkern_resched, rump_unschedulefn rumpkern_unsched)
{
- return RUMPUSER_VERSION;
+ if (version != RUMPUSER_VERSION) {
+ fprintf(stderr, "rumpuser mismatch, kern: %d, hypervisor %d\n",
+ version, RUMPUSER_VERSION);
+ return 1;
+ }
+
+#ifdef RUMPUSER_USE_RANDOM
+ uint32_t rv;
+ int fd;
+
+ if ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
+ srandom(time(NULL));
+ } else {
+ if (read(fd, &rv, sizeof(rv)) != sizeof(rv))
+ srandom(time(NULL));
+ else
+ srandom(rv);
+ close(fd);
+ }
+#endif
+
+ rumpuser__thrinit();
+
+ rumpuser__unschedule = rumpkern_unsched;
+ rumpuser__reschedule = rumpkern_resched;
+
+ return 0;
}
int
diff -r 87cb176b54f5 -r 5f692773c4ae lib/librumpuser/rumpuser_component.c
--- a/lib/librumpuser/rumpuser_component.c Sat Apr 27 14:02:17 2013 +0000
+++ b/lib/librumpuser/rumpuser_component.c Sat Apr 27 14:59:08 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_component.c,v 1.1 2013/03/01 18:15:36 pooka Exp $ */
+/* $NetBSD: rumpuser_component.c,v 1.2 2013/04/27 14:59:08 pooka Exp $ */
/*
* Copyright (c) 2013 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_component.c,v 1.1 2013/03/01 18:15:36 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_component.c,v 1.2 2013/04/27 14:59:08 pooka Exp $");
#endif /* !lint */
/*
@@ -47,7 +47,7 @@
{
int nlocks;
- rumpuser__kunlock(0, &nlocks, NULL);
+ rumpuser__unschedule(0, &nlocks, NULL);
return (void *)(intptr_t)nlocks;
}
@@ -56,5 +56,5 @@
{
int nlocks = (int)(intptr_t)cookie;
- rumpuser__klock(nlocks, NULL);
+ rumpuser__reschedule(nlocks, NULL);
}
diff -r 87cb176b54f5 -r 5f692773c4ae lib/librumpuser/rumpuser_int.h
--- a/lib/librumpuser/rumpuser_int.h Sat Apr 27 14:02:17 2013 +0000
+++ b/lib/librumpuser/rumpuser_int.h Sat Apr 27 14:59:08 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_int.h,v 1.4 2010/11/15 15:23:32 pooka Exp $ */
+/* $NetBSD: rumpuser_int.h,v 1.5 2013/04/27 14:59:08 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -29,18 +29,17 @@
#include <rump/rumpuser.h>
-extern kernel_lockfn rumpuser__klock;
-extern kernel_unlockfn rumpuser__kunlock;
-extern int rumpuser__wantthreads;
+extern rump_unschedulefn rumpuser__unschedule;
+extern rump_reschedulefn rumpuser__reschedule;
#define seterror(value) do { if (error) *error = value;} while (/*CONSTCOND*/0)
#define KLOCK_WRAP(a) \
do { \
int nlocks; \
- rumpuser__kunlock(0, &nlocks, NULL); \
+ rumpuser__unschedule(0, &nlocks, NULL); \
a; \
- rumpuser__klock(nlocks, NULL); \
+ rumpuser__reschedule(nlocks, NULL); \
} while (/*CONSTCOND*/0)
#define DOCALL(rvtype, call) \
@@ -58,12 +57,14 @@
{ \
rvtype rv; \
int nlocks; \
- rumpuser__kunlock(0, &nlocks, NULL); \
+ rumpuser__unschedule(0, &nlocks, NULL); \
rv = call; \
- rumpuser__klock(nlocks, NULL); \
+ rumpuser__reschedule(nlocks, NULL); \
if (rv == -1) \
seterror(errno); \
else \
seterror(0); \
return rv; \
}
+
+void rumpuser__thrinit(void);
diff -r 87cb176b54f5 -r 5f692773c4ae lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c Sat Apr 27 14:02:17 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth.c Sat Apr 27 14:59:08 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.13 2013/04/27 13:59:46 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.14 2013/04/27 14:59:08 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.13 2013/04/27 13:59:46 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.14 2013/04/27 14:59:08 pooka Exp $");
#endif /* !lint */
#include <assert.h>
@@ -113,9 +113,14 @@
int rumpuser_aio_head, rumpuser_aio_tail;
struct rumpuser_aio rumpuser_aios[N_AIOS];
-kernel_lockfn rumpuser__klock;
-kernel_unlockfn rumpuser__kunlock;
-int rumpuser__wantthreads;
+void
+rumpuser__thrinit(void)
+{
+
+ pthread_mutex_init(&rumpuser_aio_mtx.pthmtx, NULL);
+ pthread_cond_init(&rumpuser_aio_cv.pthcv, NULL);
+ pthread_key_create(&curlwpkey, NULL);
+}
void
/*ARGSUSED*/
@@ -127,7 +132,7 @@
int error, dummy;
/* unschedule from CPU. we reschedule before running the interrupt */
- rumpuser__kunlock(0, &dummy, NULL);
+ rumpuser__unschedule(0, &dummy, NULL);
assert(dummy == 0);
NOFAIL_ERRNO(pthread_mutex_lock(&rumpuser_aio_mtx.pthmtx));
@@ -165,9 +170,9 @@
#endif
}
}
- rumpuser__klock(0, NULL);
+ rumpuser__reschedule(0, NULL);
biodone(rua->rua_bp, (size_t)rv, error);
- rumpuser__kunlock(0, &dummy, NULL);
+ rumpuser__unschedule(0, &dummy, NULL);
rua->rua_bp = NULL;
@@ -181,44 +186,6 @@
abort();
}
-void
-rumpuser_thrinit(kernel_lockfn lockfn, kernel_unlockfn unlockfn, int threads)
-{
-#ifdef RUMPUSER_USE_RANDOM
- /* XXX: there's no rumpuser_bootstrap, so do this here */
- uint32_t rv;
- int fd;
-
- if ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
- srandom(time(NULL));
- } else {
- if (read(fd, &rv, sizeof(rv)) != sizeof(rv))
- srandom(time(NULL));
- else
- srandom(rv);
- close(fd);
- }
-#endif
-
- pthread_mutex_init(&rumpuser_aio_mtx.pthmtx, NULL);
- pthread_cond_init(&rumpuser_aio_cv.pthcv, NULL);
-
- pthread_key_create(&curlwpkey, NULL);
-
- rumpuser__klock = lockfn;
- rumpuser__kunlock = unlockfn;
- rumpuser__wantthreads = threads;
-}
-
-#if 0
-void
-rumpuser__thrdestroy(void)
-{
-
- pthread_key_delete(curlwpkey);
-}
-#endif
-
int
rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
int joinable, void **ptcookie)
@@ -504,11 +471,11 @@
int nlocks;
cv->nwaiters++;
- rumpuser__kunlock(0, &nlocks, mtx);
+ rumpuser__unschedule(0, &nlocks, mtx);
mtxexit(mtx);
NOFAIL_ERRNO(pthread_cond_wait(&cv->pthcv, &mtx->pthmtx));
mtxenter(mtx);
- rumpuser__klock(nlocks, mtx);
+ rumpuser__reschedule(nlocks, mtx);
cv->nwaiters--;
}
@@ -534,11 +501,11 @@
ts.tv_sec = sec; ts.tv_nsec = nsec;
cv->nwaiters++;
- rumpuser__kunlock(0, &nlocks, mtx);
+ rumpuser__unschedule(0, &nlocks, mtx);
mtxexit(mtx);
rv = pthread_cond_timedwait(&cv->pthcv, &mtx->pthmtx, &ts);
mtxenter(mtx);
- rumpuser__klock(nlocks, mtx);
+ rumpuser__reschedule(nlocks, mtx);
cv->nwaiters--;
if (rv != 0 && rv != ETIMEDOUT)
abort();
diff -r 87cb176b54f5 -r 5f692773c4ae lib/librumpuser/rumpuser_pth_dummy.c
--- a/lib/librumpuser/rumpuser_pth_dummy.c Sat Apr 27 14:02:17 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth_dummy.c Sat Apr 27 14:59:08 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth_dummy.c,v 1.8 2013/04/27 13:59:46 pooka Exp $ */
+/* $NetBSD: rumpuser_pth_dummy.c,v 1.9 2013/04/27 14:59:08 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.8 2013/04/27 13:59:46 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.9 2013/04/27 14:59:08 pooka Exp $");
#endif /* !lint */
#include <sys/time.h>
@@ -63,16 +63,11 @@
int rumpuser_aio_head, rumpuser_aio_tail;
struct rumpuser_aio rumpuser_aios[N_AIOS];
-kernel_lockfn rumpuser__klock;
-kernel_unlockfn rumpuser__kunlock;
-
Home |
Main Index |
Thread Index |
Old Index