Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpkern Almost there for virtual CPU MP su...
details: https://anonhg.NetBSD.org/src/rev/96b910e84c9a
branches: trunk
changeset: 749516:96b910e84c9a
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Dec 01 09:50:51 2009 +0000
description:
Almost there for virtual CPU MP support:
* support bound kernel threads
* bind softint threads to specific virtual cpus
+ remove now-unnecessary locks from softint code
Now, if we only had MI CPU_INFO_FOREACH() .... (hi rmind ;)
diffstat:
sys/rump/librump/rumpkern/intr.c | 108 +++++++++++++++++++-----------
sys/rump/librump/rumpkern/locks.c | 10 ++-
sys/rump/librump/rumpkern/rump.c | 22 ++++-
sys/rump/librump/rumpkern/rump_private.h | 4 +-
sys/rump/librump/rumpkern/scheduler.c | 90 ++++++++++++++++++++-----
sys/rump/librump/rumpkern/threads.c | 11 +-
6 files changed, 172 insertions(+), 73 deletions(-)
diffs (truncated from 528 to 300 lines):
diff -r d26f7d8b7774 -r 96b910e84c9a sys/rump/librump/rumpkern/intr.c
--- a/sys/rump/librump/rumpkern/intr.c Tue Dec 01 09:28:02 2009 +0000
+++ b/sys/rump/librump/rumpkern/intr.c Tue Dec 01 09:50:51 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.21 2009/11/11 16:46:50 pooka Exp $ */
+/* $NetBSD: intr.c,v 1.22 2009/12/01 09:50:51 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2009/11/11 16:46:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.22 2009/12/01 09:50:51 pooka Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -58,10 +58,10 @@
};
static struct rumpuser_mtx *si_mtx;
-static struct softint_lev {
+struct softint_lev {
struct rumpuser_cv *si_cv;
LIST_HEAD(, softint) si_pending;
-} softints[SOFTINT_COUNT];
+};
/* rumpuser structures since we call rumpuser interfaces directly */
static struct rumpuser_cv *clockcv;
@@ -117,16 +117,18 @@
for (;;) {
callout_hardclock();
+ /* wait until the next tick. XXX: what if the clock changes? */
+ while (rumpuser_cv_timedwait(clockcv, clockmtx,
+ curtime.tv_sec, curtime.tv_nsec) == 0)
+ continue;
+
+ /* if !maincpu: continue */
+
if (++ticks == hz) {
time_uptime++;
ticks = 0;
}
- /* wait until the next tick. XXX: what if the clock changes? */
- while (rumpuser_cv_timedwait(clockcv, clockmtx,
- curtime.tv_sec, curtime.tv_nsec) == 0)
- continue;
-
clkgen++;
timespecadd(&clockup, &tick, &clockup);
clkgen++;
@@ -147,11 +149,18 @@
void *funarg;
bool mpsafe;
int mylevel = (uintptr_t)arg;
- struct softint_lev *si_lvl;
+ struct softint_lev *si_lvlp, *si_lvl;
+ struct cpu_data *cd = &curcpu()->ci_data;
rump_unschedule();
- si_lvl = &softints[mylevel];
+ si_lvlp = cd->cpu_softcpu;
+ si_lvl = &si_lvlp[mylevel];
+
+ /*
+ * XXX: si_mtx is unnecessary, and should open an interface
+ * which allows to use schedmtx for the cv wait
+ */
rumpuser_mutex_enter_nowrap(si_mtx);
for (;;) {
if (!LIST_EMPTY(&si_lvl->si_pending)) {
@@ -191,38 +200,54 @@
}
void
-softint_init(struct cpu_info *ci)
+rump_intr_init()
{
- int rv, i;
rumpuser_mutex_init(&si_mtx);
- for (i = 0; i < SOFTINT_COUNT; i++) {
- rumpuser_cv_init(&softints[i].si_cv);
- LIST_INIT(&softints[i].si_pending);
- }
-
rumpuser_cv_init(&clockcv);
rumpuser_mutex_init(&clockmtx);
+}
- /* XXX: should have separate "wanttimer" control */
- if (rump_threads) {
- for (i = 0; i < SOFTINT_COUNT; i++) {
- rv = kthread_create(PRI_NONE,
- KTHREAD_MPSAFE | KTHREAD_INTR, NULL,
- sithread, (void *)(uintptr_t)i,
- NULL, "rumpsi%d", i);
- }
+void
+softint_init(struct cpu_info *ci)
+{
+ struct cpu_data *cd = &ci->ci_data;
+ struct softint_lev *slev;
+ int rv, i;
+
+ if (!rump_threads)
+ return;
- rumpuser_mutex_enter(clockmtx);
- rv = kthread_create(PRI_NONE, KTHREAD_MPSAFE | KTHREAD_INTR,
- NULL, doclock, NULL, NULL, "rumpclk");
+ slev = kmem_alloc(sizeof(struct softint_lev) * SOFTINT_COUNT, KM_SLEEP);
+ for (i = 0; i < SOFTINT_COUNT; i++) {
+ rumpuser_cv_init(&slev[i].si_cv);
+ LIST_INIT(&slev[i].si_pending);
+ }
+ cd->cpu_softcpu = slev;
+
+ for (i = 0; i < SOFTINT_COUNT; i++) {
+ rv = kthread_create(PRI_NONE,
+ KTHREAD_MPSAFE | KTHREAD_INTR, NULL,
+ sithread, (void *)(uintptr_t)i,
+ NULL, "rumpsi%d", i);
+ }
+
+ rumpuser_mutex_enter(clockmtx);
+ for (i = 0; i < ncpu; i++) {
+ rv = kthread_create(PRI_NONE,
+ KTHREAD_MPSAFE | KTHREAD_INTR,
+ cpu_lookup(i), doclock, NULL, NULL,
+ "rumpclk%d", i);
if (rv)
panic("clock thread creation failed: %d", rv);
+ }
- /* make sure we have a clocktime before returning */
- rumpuser_cv_wait(clockcv, clockmtx);
- rumpuser_mutex_exit(clockmtx);
- }
+ /*
+ * Make sure we have a clocktime before returning.
+ * XXX: mp
+ */
+ rumpuser_cv_wait(clockcv, clockmtx);
+ rumpuser_mutex_exit(clockmtx);
}
/*
@@ -254,17 +279,17 @@
softint_schedule(void *arg)
{
struct softint *si = arg;
+ struct cpu_data *cd = &curcpu()->ci_data;
+ struct softint_lev *si_lvl = cd->cpu_softcpu;
if (!rump_threads) {
si->si_func(si->si_arg);
} else {
- rumpuser_mutex_enter(si_mtx);
if (!(si->si_flags & SI_ONLIST)) {
- LIST_INSERT_HEAD(&softints[si->si_level].si_pending,
+ LIST_INSERT_HEAD(&si_lvl[si->si_level].si_pending,
si, si_entries);
si->si_flags |= SI_ONLIST;
}
- rumpuser_mutex_exit(si_mtx);
}
}
@@ -286,14 +311,17 @@
void
rump_softint_run(struct cpu_info *ci)
{
+ struct cpu_data *cd = &ci->ci_data;
+ struct softint_lev *si_lvl = cd->cpu_softcpu;
int i;
- rumpuser_mutex_enter_nowrap(si_mtx);
+ if (!rump_threads)
+ return;
+
for (i = 0; i < SOFTINT_COUNT; i++) {
- if (!LIST_EMPTY(&softints[i].si_pending))
- rumpuser_cv_signal(softints[i].si_cv);
+ if (!LIST_EMPTY(&si_lvl[i].si_pending))
+ rumpuser_cv_signal(si_lvl[i].si_cv);
}
- rumpuser_mutex_exit(si_mtx);
}
bool
diff -r d26f7d8b7774 -r 96b910e84c9a sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Tue Dec 01 09:28:02 2009 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Tue Dec 01 09:50:51 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locks.c,v 1.35 2009/11/26 17:29:34 pooka Exp $ */
+/* $NetBSD: locks.c,v 1.36 2009/12/01 09:50:51 pooka Exp $ */
/*
* Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.35 2009/11/26 17:29:34 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.36 2009/12/01 09:50:51 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -330,7 +330,7 @@
if (!rumpuser_mutex_tryenter(rump_giantlock)) {
struct lwp *l = curlwp;
- rump_unschedule_cpu(l);
+ rump_unschedule_cpu1(l);
rumpuser_mutex_enter_nowrap(rump_giantlock);
rump_schedule_cpu(l);
}
@@ -369,6 +369,10 @@
{
_kernel_unlock(nlocks, countp);
+ /*
+ * XXX: technically we should unschedule_cpu1() here, but that
+ * requires rump_intr_enter/exit to be implemented.
+ */
rump_unschedule_cpu(curlwp);
}
diff -r d26f7d8b7774 -r 96b910e84c9a sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Tue Dec 01 09:28:02 2009 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Tue Dec 01 09:50:51 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.142 2009/11/27 17:55:04 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.143 2009/12/01 09:50:51 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.142 2009/11/27 17:55:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.143 2009/12/01 09:50:51 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -60,6 +60,7 @@
#include <sys/tty.h>
#include <sys/uidinfo.h>
#include <sys/vmem.h>
+#include <sys/xcall.h>
#include <rump/rumpuser.h>
@@ -180,6 +181,7 @@
char buf[256];
struct proc *p;
struct lwp *l;
+ int i;
int error;
/* not reentrant */
@@ -209,6 +211,7 @@
}
rumpuser_thrinit(rump_user_schedule, rump_user_unschedule,
rump_threads);
+ rump_intr_init();
/* init minimal lwp/cpu context */
l = &lwp0;
@@ -233,6 +236,7 @@
uvm_ra_init();
mutex_obj_init();
+ callout_startup();
kprintf_init();
loginit();
@@ -266,9 +270,16 @@
rumpuser_set_curlwp(NULL);
rump_schedule();
- callout_startup();
- callout_init_cpu(rump_cpu);
- selsysinit(rump_cpu);
+ /* we are mostly go. do per-cpu subsystem init */
+ for (i = 0; i < ncpu; i++) {
+ struct cpu_info *ci = cpu_lookup(i);
+
+ callout_init_cpu(ci);
+ softint_init(ci);
+ xc_init_cpu(ci);
+ pool_cache_cpu_init(ci);
+ selsysinit(ci);
Home |
Main Index |
Thread Index |
Old Index