Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add RUMPUSER_LWP_CLEAR instead of overloading RUMPUSER_LWP_SET.
details: https://anonhg.NetBSD.org/src/rev/66b337e482fc
branches: trunk
changeset: 786844:66b337e482fc
user: pooka <pooka%NetBSD.org@localhost>
date: Wed May 15 14:07:26 2013 +0000
description:
Add RUMPUSER_LWP_CLEAR instead of overloading RUMPUSER_LWP_SET.
This simplifies some alternative hypervisor implementations.
diffstat:
lib/librumpuser/rumpuser.3 | 19 ++++++++++-----
lib/librumpuser/rumpuser_pth.c | 41 +++++++++++++++++++---------------
sys/rump/include/rump/rumpuser.h | 7 ++++-
sys/rump/librump/rumpkern/lwproc.c | 6 ++--
sys/rump/librump/rumpkern/rump.c | 6 ++--
sys/rump/librump/rumpkern/scheduler.c | 8 +++---
6 files changed, 50 insertions(+), 37 deletions(-)
diffs (229 lines):
diff -r 9c5482d1ccec -r 66b337e482fc lib/librumpuser/rumpuser.3
--- a/lib/librumpuser/rumpuser.3 Wed May 15 13:58:14 2013 +0000
+++ b/lib/librumpuser/rumpuser.3 Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rumpuser.3,v 1.9 2013/05/03 20:27:16 wiz Exp $
+.\" $NetBSD: rumpuser.3,v 1.10 2013/05/15 14:07:26 pooka Exp $
.\"
.\" Copyright (c) 2013 Antti Kantee. All rights reserved.
.\"
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 2, 2013
+.Dd May 15, 2013
.Dt RUMPUSER 3
.Os
.Sh NAME
@@ -475,10 +475,14 @@
Set
.Fa l
as the current host thread's rump kernel context.
-The value
-.Dv NULL
-means that an existing rump kernel context (which must exist)
-must be cleared.
+A previous context must not exist.
+.It Dv RUMPUSER_LWP_CLEAR
+Clear the context previous set by
+.Dv RUMPUSER_LWP_SET .
+The value passed in
+.Fa l
+is the current thread and is never
+.Dv NULL.
.El
.Pp
.Ft struct lwp *
@@ -641,7 +645,8 @@
.%A Antti Kantee
.%D 2012
.%J Aalto University Doctoral Dissertations
-.%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernerls
+.%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernels
+.%O Section 2.3.2: The Hypercall Interface
.Re
.Sh HISTORY
The rump kernel hypercall API was first introduced in
diff -r 9c5482d1ccec -r 66b337e482fc lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c Wed May 15 13:58:14 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth.c Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.28 2013/05/05 12:27:38 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.29 2013/05/15 14:07:26 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.28 2013/05/05 12:27:38 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.29 2013/05/15 14:07:26 pooka Exp $");
#endif /* !lint */
#include <sys/queue.h>
@@ -627,26 +627,27 @@
free(rl);
break;
case RUMPUSER_LWP_SET:
- assert(pthread_getspecific(curlwpkey) == NULL || l == NULL);
+ assert(pthread_getspecific(curlwpkey) == NULL && l != NULL);
- if (l) {
- pthread_mutex_lock(&lwplock);
- LIST_FOREACH(rl, &lwps, l_entries) {
- if (rl->l == l)
- break;
- }
- if (!rl) {
- fprintf(stderr,
- "LWP_SET: %p does not exist\n", l);
- abort();
- }
- pthread_mutex_unlock(&lwplock);
- } else {
- rl = NULL;
+ pthread_mutex_lock(&lwplock);
+ LIST_FOREACH(rl, &lwps, l_entries) {
+ if (rl->l == l)
+ break;
}
+ if (!rl) {
+ fprintf(stderr,
+ "LWP_SET: %p does not exist\n", l);
+ abort();
+ }
+ pthread_mutex_unlock(&lwplock);
pthread_setspecific(curlwpkey, rl);
break;
+ case RUMPUSER_LWP_CLEAR:
+ assert(((struct rumpuser_lwp *)
+ pthread_getspecific(curlwpkey))->l == l);
+ pthread_setspecific(curlwpkey, NULL);
+ break;
}
}
@@ -671,9 +672,13 @@
case RUMPUSER_LWP_DESTROY:
break;
case RUMPUSER_LWP_SET:
- assert(pthread_getspecific(curlwpkey) == NULL || l == NULL);
+ assert(pthread_getspecific(curlwpkey) == NULL);
pthread_setspecific(curlwpkey, l);
break;
+ case RUMPUSER_LWP_CLEAR:
+ assert(pthread_getspecific(curlwpkey) == l);
+ pthread_setspecific(curlwpkey, NULL);
+ break;
}
}
diff -r 9c5482d1ccec -r 66b337e482fc sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Wed May 15 13:58:14 2013 +0000
+++ b/sys/rump/include/rump/rumpuser.h Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.103 2013/05/02 21:45:28 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.104 2013/05/15 14:07:26 pooka Exp $ */
/*
* Copyright (c) 2007-2013 Antti Kantee. All Rights Reserved.
@@ -164,7 +164,10 @@
void rumpuser_thread_exit(void) __dead;
int rumpuser_thread_join(void *);
-enum rumplwpop { RUMPUSER_LWP_CREATE, RUMPUSER_LWP_DESTROY, RUMPUSER_LWP_SET };
+enum rumplwpop {
+ RUMPUSER_LWP_CREATE, RUMPUSER_LWP_DESTROY,
+ RUMPUSER_LWP_SET, RUMPUSER_LWP_CLEAR
+};
void rumpuser_curlwpop(enum rumplwpop, struct lwp *);
struct lwp *rumpuser_curlwp(void);
diff -r 9c5482d1ccec -r 66b337e482fc sys/rump/librump/rumpkern/lwproc.c
--- a/sys/rump/librump/rumpkern/lwproc.c Wed May 15 13:58:14 2013 +0000
+++ b/sys/rump/librump/rumpkern/lwproc.c Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwproc.c,v 1.22 2013/05/02 19:15:01 pooka Exp $ */
+/* $NetBSD: lwproc.c,v 1.23 2013/05/15 14:07:26 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.22 2013/05/02 19:15:01 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.23 2013/05/15 14:07:26 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -352,7 +352,7 @@
fd_free();
}
- rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
+ rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
newlwp->l_cpu = newlwp->l_target_cpu = l->l_cpu;
newlwp->l_mutex = l->l_mutex;
diff -r 9c5482d1ccec -r 66b337e482fc sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Wed May 15 13:58:14 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.268 2013/05/02 21:45:28 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.269 2013/05/15 14:07:26 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.268 2013/05/02 21:45:28 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.269 2013/05/15 14:07:26 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -346,7 +346,7 @@
rump_scheduler_init(numcpu);
/* revert temporary context and schedule a semireal context */
- rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
+ rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
initproc = &proc0; /* borrow proc0 before we get initproc started */
rump_schedule();
bootlwp = curlwp;
diff -r 9c5482d1ccec -r 66b337e482fc sys/rump/librump/rumpkern/scheduler.c
--- a/sys/rump/librump/rumpkern/scheduler.c Wed May 15 13:58:14 2013 +0000
+++ b/sys/rump/librump/rumpkern/scheduler.c Wed May 15 14:07:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scheduler.c,v 1.33 2013/05/02 19:15:01 pooka Exp $ */
+/* $NetBSD: scheduler.c,v 1.34 2013/05/15 14:07:26 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.33 2013/05/02 19:15:01 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.34 2013/05/15 14:07:26 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -399,10 +399,10 @@
lwp0.l_mutex = &unruntime_lock;
lwp0.l_pflag &= ~LP_RUNNING;
lwp0rele();
- rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
+ rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, &lwp0);
} else if (__predict_false(l->l_flag & LW_RUMP_CLEAR)) {
- rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
+ rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
l->l_flag &= ~LW_RUMP_CLEAR;
}
}
Home |
Main Index |
Thread Index |
Old Index