Module Name: src
Committed By: pooka
Date: Fri Oct 16 00:14:53 UTC 2009
Modified Files:
src/sys/rump/librump/rumpkern: Makefile.rumpkern emul.c locks.c rump.c
rump_private.h scheduler.c sleepq.c vm.c
Log Message:
Include sys_select.c for proper select()/poll() support.
To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/rump/librump/rumpkern/Makefile.rumpkern
cvs rdiff -u -r1.102 -r1.103 src/sys/rump/librump/rumpkern/emul.c
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/librump/rumpkern/locks.c
cvs rdiff -u -r1.125 -r1.126 src/sys/rump/librump/rumpkern/rump.c
cvs rdiff -u -r1.33 -r1.34 src/sys/rump/librump/rumpkern/rump_private.h
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/librump/rumpkern/scheduler.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpkern/sleepq.c
cvs rdiff -u -r1.61 -r1.62 src/sys/rump/librump/rumpkern/vm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern
diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.52 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.53
--- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.52 Thu Oct 15 00:28:46 2009
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.rumpkern,v 1.52 2009/10/15 00:28:46 pooka Exp $
+# $NetBSD: Makefile.rumpkern,v 1.53 2009/10/16 00:14:53 pooka Exp $
#
.include "${RUMPTOP}/Makefile.rump"
@@ -34,7 +34,7 @@
SRCS+= init_sysctl_base.c kern_auth.c kern_descrip.c kern_event.c \
kern_ksyms.c kern_malloc_stdtype.c kern_module.c kern_rate.c \
kern_stub.c kern_sysctl.c kern_timeout.c kern_uidinfo.c param.c \
- sys_descrip.c sys_generic.c syscalls.c
+ sys_descrip.c sys_generic.c sys_select.c syscalls.c
# sys/kern subr (misc)
SRCS+= subr_devsw.c subr_callback.c subr_evcnt.c subr_extent.c \
Index: src/sys/rump/librump/rumpkern/emul.c
diff -u src/sys/rump/librump/rumpkern/emul.c:1.102 src/sys/rump/librump/rumpkern/emul.c:1.103
--- src/sys/rump/librump/rumpkern/emul.c:1.102 Thu Oct 15 16:39:22 2009
+++ src/sys/rump/librump/rumpkern/emul.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: emul.c,v 1.102 2009/10/15 16:39:22 pooka Exp $ */
+/* $NetBSD: emul.c,v 1.103 2009/10/16 00:14:53 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.102 2009/10/15 16:39:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.103 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -93,7 +93,6 @@
const char *domainname;
int domainnamelen;
-const struct filterops seltrue_filtops;
const struct filterops sig_filtops;
#define DEVSW_SIZE 255
@@ -487,7 +486,7 @@
case SIGSYS:
break;
default:
- panic("unhandled signal %d", signo);
+ panic("unhandled signal %d\n", signo);
}
}
@@ -577,32 +576,6 @@
return t;
}
-int
-seltrue(dev_t dev, int events, struct lwp *l)
-{
- return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
-}
-
-void
-selrecord(lwp_t *selector, struct selinfo *sip)
-{
-}
-
-void
-selinit(struct selinfo *sip)
-{
-}
-
-void
-selnotify(struct selinfo *sip, int events, long knhint)
-{
-}
-
-void
-seldestroy(struct selinfo *sip)
-{
-}
-
const char *
device_xname(device_t dv)
{
@@ -741,39 +714,6 @@
rumpuser_exit(0);
}
-/*
- * XXX: from sys_select.c, see that file for license.
- * (these will go away really soon in favour of the real sys_select.c)
- * ((really, the select code just needs cleanup))
- * (((seriously)))
- */
-int
-inittimeleft(struct timespec *ts, struct timespec *sleepts)
-{
- if (itimespecfix(ts))
- return -1;
- getnanouptime(sleepts);
- return 0;
-}
-
-int
-gettimeleft(struct timespec *ts, struct timespec *sleepts)
-{
- /*
- * We have to recalculate the timeout on every retry.
- */
- struct timespec sleptts;
- /*
- * reduce ts by elapsed time
- * based on monotonic time scale
- */
- getnanouptime(&sleptts);
- timespecadd(ts, sleepts, ts);
- timespecsub(ts, &sleptts, ts);
- *sleepts = sleptts;
- return tstohz(ts);
-}
-
bool
pmf_device_register1(struct device *dev,
bool (*suspend)(device_t PMF_FN_PROTO),
Index: src/sys/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.31 src/sys/rump/librump/rumpkern/locks.c:1.32
--- src/sys/rump/librump/rumpkern/locks.c:1.31 Thu Oct 15 23:15:55 2009
+++ src/sys/rump/librump/rumpkern/locks.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: locks.c,v 1.31 2009/10/15 23:15:55 pooka Exp $ */
+/* $NetBSD: locks.c,v 1.32 2009/10/16 00:14:53 pooka Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.31 2009/10/15 23:15:55 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.32 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -347,7 +347,7 @@
rump_unschedule_cpu(l);
rumpuser_mutex_enter_nowrap(rump_giantlock);
- l->l_cpu = rump_schedule_cpu();
+ rump_schedule_cpu(l);
}
lockcnt++;
}
@@ -391,7 +391,7 @@
rump_user_schedule(int nlocks)
{
- curlwp->l_cpu = rump_schedule_cpu();
+ rump_schedule_cpu(curlwp);
if (nlocks)
_kernel_lock(nlocks);
Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.125 src/sys/rump/librump/rumpkern/rump.c:1.126
--- src/sys/rump/librump/rumpkern/rump.c:1.125 Thu Oct 15 16:39:22 2009
+++ src/sys/rump/librump/rumpkern/rump.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.125 2009/10/15 16:39:22 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.126 2009/10/16 00:14:53 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.125 2009/10/15 16:39:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.126 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -115,8 +115,8 @@
static int rump_inited;
static struct emul emul_rump;
-void rump__unavailable(void);
-void rump__unavailable() {}
+int rump__unavailable(void);
+int rump__unavailable() {return EOPNOTSUPP;}
__weak_alias(rump_net_init,rump__unavailable);
__weak_alias(rump_vfs_init,rump__unavailable);
__weak_alias(rump_dev_init,rump__unavailable);
@@ -124,6 +124,7 @@
__weak_alias(rump_vfs_fini,rump__unavailable);
__weak_alias(biodone,rump__unavailable);
+__weak_alias(sopoll,rump__unavailable);
void rump__unavailable_vfs_panic(void);
void rump__unavailable_vfs_panic() {panic("vfs component not available");}
@@ -254,6 +255,7 @@
callout_startup();
callout_init_cpu(rump_cpu);
+ selsysinit(rump_cpu);
sysctl_init();
kqueue_init();
@@ -440,7 +442,6 @@
l->l_proc = p;
l->l_lid = lid;
l->l_fd = p->p_fd;
- l->l_mutex = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
l->l_cpu = NULL;
return l;
@@ -453,6 +454,9 @@
rumpuser_set_curlwp(NULL);
newlwp->l_cpu = l->l_cpu;
+ newlwp->l_mutex = l->l_mutex;
+ l->l_mutex = NULL;
+ l->l_cpu = NULL;
rumpuser_set_curlwp(newlwp);
if (l->l_flag & LW_WEXIT)
rump_lwp_free(l);
@@ -481,9 +485,8 @@
{
KASSERT(l->l_flag & LW_WEXIT);
- KASSERT(l != rumpuser_get_curlwp());
+ KASSERT(l->l_mutex == NULL);
rump_cred_put(l->l_cred);
- mutex_obj_free(l->l_mutex);
kmem_free(l, sizeof(*l));
}
Index: src/sys/rump/librump/rumpkern/rump_private.h
diff -u src/sys/rump/librump/rumpkern/rump_private.h:1.33 src/sys/rump/librump/rumpkern/rump_private.h:1.34
--- src/sys/rump/librump/rumpkern/rump_private.h:1.33 Thu Oct 15 23:15:55 2009
+++ src/sys/rump/librump/rumpkern/rump_private.h Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_private.h,v 1.33 2009/10/15 23:15:55 pooka Exp $ */
+/* $NetBSD: rump_private.h,v 1.34 2009/10/16 00:14:53 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -86,11 +86,11 @@
int rump_sysproxy_copyout(const void *, void *, size_t);
int rump_sysproxy_copyin(const void *, void *, size_t);
-void rump_scheduler_init(void);
-void rump_schedule(void);
-void rump_unschedule(void);
-struct cpu_info *rump_schedule_cpu(void);
-void rump_unschedule_cpu(struct lwp *);
+void rump_scheduler_init(void);
+void rump_schedule(void);
+void rump_unschedule(void);
+void rump_schedule_cpu(struct lwp *);
+void rump_unschedule_cpu(struct lwp *);
void rump_user_schedule(int);
void rump_user_unschedule(int, int *);
Index: src/sys/rump/librump/rumpkern/scheduler.c
diff -u src/sys/rump/librump/rumpkern/scheduler.c:1.3 src/sys/rump/librump/rumpkern/scheduler.c:1.4
--- src/sys/rump/librump/rumpkern/scheduler.c:1.3 Thu Oct 15 23:15:55 2009
+++ src/sys/rump/librump/rumpkern/scheduler.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: scheduler.c,v 1.3 2009/10/15 23:15:55 pooka Exp $ */
+/* $NetBSD: scheduler.c,v 1.4 2009/10/16 00:14:53 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.3 2009/10/15 23:15:55 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.4 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -78,6 +78,8 @@
rcpu = &rcpu_storage[i];
ci = &rump_cpus[i];
rump_cpu_bootstrap(ci);
+ ci->ci_schedstate.spc_mutex =
+ mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
rcpu->rcpu_ci = ci;
SLIST_INSERT_HEAD(&cpu_freelist, rcpu, rcpu_entries);
}
@@ -86,7 +88,6 @@
void
rump_schedule()
{
- struct cpu_info *ci;
struct lwp *l;
/*
@@ -104,8 +105,7 @@
rumpuser_mutex_exit(schedmtx);
/* schedule cpu and use lwp0 */
- ci = rump_schedule_cpu();
- lwp0.l_cpu = ci;
+ rump_schedule_cpu(&lwp0);
rumpuser_set_curlwp(&lwp0);
l = rump_lwp_alloc(0, rump_nextlid());
@@ -119,14 +119,12 @@
/* mark new lwp as dead-on-exit */
rump_lwp_release(l);
} else {
- KASSERT(l->l_cpu == NULL);
- ci = rump_schedule_cpu();
- l->l_cpu = ci;
+ rump_schedule_cpu(l);
}
}
-struct cpu_info *
-rump_schedule_cpu()
+void
+rump_schedule_cpu(struct lwp *l)
{
struct rumpcpu *rcpu;
@@ -135,8 +133,9 @@
rumpuser_cv_wait_nowrap(schedcv, schedmtx);
SLIST_REMOVE_HEAD(&cpu_freelist, rcpu_entries);
rumpuser_mutex_exit(schedmtx);
-
- return rcpu->rcpu_ci;
+ KASSERT(l->l_cpu == NULL);
+ l->l_cpu = rcpu->rcpu_ci;
+ l->l_mutex = rcpu->rcpu_ci->ci_schedstate.spc_mutex;
}
void
@@ -145,7 +144,9 @@
struct lwp *l;
l = rumpuser_get_curlwp();
+ KASSERT(l->l_mutex == l->l_cpu->ci_schedstate.spc_mutex);
rump_unschedule_cpu(l);
+ l->l_mutex = NULL;
if (l->l_flag & LW_WEXIT) {
kmem_free(l, sizeof(*l));
rumpuser_set_curlwp(NULL);
Index: src/sys/rump/librump/rumpkern/sleepq.c
diff -u src/sys/rump/librump/rumpkern/sleepq.c:1.2 src/sys/rump/librump/rumpkern/sleepq.c:1.3
--- src/sys/rump/librump/rumpkern/sleepq.c:1.2 Thu Dec 18 00:24:12 2008
+++ src/sys/rump/librump/rumpkern/sleepq.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: sleepq.c,v 1.2 2008/12/18 00:24:12 pooka Exp $ */
+/* $NetBSD: sleepq.c,v 1.3 2009/10/16 00:14:53 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.2 2008/12/18 00:24:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.3 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -35,6 +35,8 @@
#include <sys/sleepq.h>
#include <sys/syncobj.h>
+#include "rump_private.h"
+
/*
* Flimsy and minimalistic sleepq implementation. This is implemented
* only for the use of callouts in kern_timeout.c. locking etc is
@@ -43,7 +45,6 @@
syncobj_t sleep_syncobj;
static kcondvar_t sq_cv;
-static kmutex_t sq_mtx;
void
sleepq_init(sleepq_t *sq)
@@ -52,7 +53,6 @@
TAILQ_INIT(sq);
cv_init(&sq_cv, "sleepq"); /* XXX */
- mutex_init(&sq_mtx, MUTEX_DEFAULT, IPL_NONE); /* multi-XXX */
}
void
@@ -60,39 +60,46 @@
{
struct lwp *l = curlwp;
- if (__predict_false(sob != &sleep_syncobj || strcmp(wmsg, "callout"))) {
- panic("sleepq: unsupported enqueue");
- }
-
l->l_wchan = wc;
+ l->l_sleepq = sq;
TAILQ_INSERT_TAIL(sq, l, l_sleepchain);
}
int
-sleepq_block(int timo, bool hatch)
+sleepq_block(int timo, bool catch)
{
struct lwp *l = curlwp;
+ int error = 0;
+ kmutex_t *mp = l->l_mutex;
+ int biglocks = l->l_biglocks;
- KASSERT(timo == 0 && !hatch);
+ while (l->l_wchan) {
+ if ((error=cv_timedwait(&sq_cv, mp, timo)) == EWOULDBLOCK)
+ l->l_wchan = NULL;
+ }
+ mutex_spin_exit(mp);
- mutex_enter(&sq_mtx);
- while (l->l_wchan)
- cv_wait(&sq_cv, &sq_mtx);
- mutex_exit(&sq_mtx);
+ if (biglocks)
+ KERNEL_LOCK(biglocks, curlwp);
- return 0;
+ return error;
}
lwp_t *
sleepq_wake(sleepq_t *sq, wchan_t wchan, u_int expected, kmutex_t *mp)
{
- struct lwp *l;
+ struct lwp *l, *l_next;
bool found = false;
- TAILQ_FOREACH(l, sq, l_sleepchain) {
+ if (__predict_false(expected != -1))
+ panic("sleepq_wake: \"expected\" not supported");
+
+ for (l = TAILQ_FIRST(sq); l; l = l_next) {
+ l_next = TAILQ_NEXT(l, l_sleepchain);
if (l->l_wchan == wchan) {
found = true;
l->l_wchan = NULL;
+ TAILQ_REMOVE(sq, l, l_sleepchain);
}
}
if (found)
@@ -102,15 +109,56 @@
return NULL;
}
+u_int
+sleepq_unsleep(struct lwp *l, bool cleanup)
+{
+
+ l->l_wchan = NULL;
+ TAILQ_REMOVE(l->l_sleepq, l, l_sleepchain);
+ cv_broadcast(&sq_cv);
+
+ if (cleanup) {
+ mutex_spin_exit(l->l_mutex);
+ }
+
+ return 0;
+}
+
/*
- * XXX: used only by callout, therefore here
- *
- * We don't fudge around with the lwp mutex at all, therefore
- * this is enough.
+ * Thread scheduler handles priorities. Therefore no action here.
+ * (maybe do something if we're deperate?)
+ */
+void
+sleepq_changepri(struct lwp *l, pri_t pri)
+{
+
+}
+
+void
+sleepq_lendpri(struct lwp *l, pri_t pri)
+{
+
+}
+
+struct lwp *
+syncobj_noowner(wchan_t wc)
+{
+
+ return NULL;
+}
+
+/*
+ * XXX: used only by callout, therefore here. should try to use
+ * one in kern_lwp directly.
*/
kmutex_t *
lwp_lock_retry(struct lwp *l, kmutex_t *old)
{
+ while (l->l_mutex != old) {
+ mutex_spin_exit(old);
+ old = l->l_mutex;
+ mutex_spin_enter(old);
+ }
return old;
}
Index: src/sys/rump/librump/rumpkern/vm.c
diff -u src/sys/rump/librump/rumpkern/vm.c:1.61 src/sys/rump/librump/rumpkern/vm.c:1.62
--- src/sys/rump/librump/rumpkern/vm.c:1.61 Tue Aug 4 23:58:29 2009
+++ src/sys/rump/librump/rumpkern/vm.c Fri Oct 16 00:14:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vm.c,v 1.61 2009/08/04 23:58:29 pooka Exp $ */
+/* $NetBSD: vm.c,v 1.62 2009/10/16 00:14:53 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.61 2009/08/04 23:58:29 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.62 2009/10/16 00:14:53 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -715,3 +715,10 @@
/* nada */
}
+
+void
+uvm_kick_scheduler(void)
+{
+
+ /* ouch */
+}