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 Don't allow kernel threads to run ...
details: https://anonhg.NetBSD.org/src/rev/3160c329d49b
branches: trunk
changeset: 785352:3160c329d49b
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Mar 10 16:51:31 2013 +0000
description:
Don't allow kernel threads to run before all CPUs have been initialized
to avoid them getting scheduled on non-initialized CPUs.
diffstat:
sys/rump/librump/rumpkern/rump.c | 8 +++++-
sys/rump/librump/rumpkern/rump_private.h | 5 +++-
sys/rump/librump/rumpkern/threads.c | 36 ++++++++++++++++++++++++++++++-
3 files changed, 44 insertions(+), 5 deletions(-)
diffs (124 lines):
diff -r 7e51c71498f0 -r 3160c329d49b sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Sun Mar 10 16:27:11 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Sun Mar 10 16:51:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.255 2013/03/08 19:04:28 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.256 2013/03/10 16:51:31 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.255 2013/03/08 19:04:28 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.256 2013/03/10 16:51:31 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -267,6 +267,7 @@
} else {
numcpu = rumpuser_getnhostcpu();
}
+ rump_thread_init();
rump_cpus_bootstrap(&numcpu);
rumpuser_gettime(&sec, &nsec, &error);
@@ -385,6 +386,9 @@
aprint_verbose("cpu%d at thinair0: rump virtual cpu\n", i);
}
+ /* CPUs are up. allow kernel threads to run */
+ rump_thread_allow();
+
mksysctls();
kqueue_init();
iostat_init();
diff -r 7e51c71498f0 -r 3160c329d49b sys/rump/librump/rumpkern/rump_private.h
--- a/sys/rump/librump/rumpkern/rump_private.h Sun Mar 10 16:27:11 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump_private.h Sun Mar 10 16:51:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_private.h,v 1.73 2013/02/19 09:04:54 martin Exp $ */
+/* $NetBSD: rump_private.h,v 1.74 2013/03/10 16:51:31 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -141,4 +141,7 @@
void rump_xc_highpri(struct cpu_info *);
+void rump_thread_init(void);
+void rump_thread_allow(void);
+
#endif /* _SYS_RUMP_PRIVATE_H_ */
diff -r 7e51c71498f0 -r 3160c329d49b sys/rump/librump/rumpkern/threads.c
--- a/sys/rump/librump/rumpkern/threads.c Sun Mar 10 16:27:11 2013 +0000
+++ b/sys/rump/librump/rumpkern/threads.c Sun Mar 10 16:51:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: threads.c,v 1.17 2012/11/04 14:40:47 pooka Exp $ */
+/* $NetBSD: threads.c,v 1.18 2013/03/10 16:51:31 pooka Exp $ */
/*
* Copyright (c) 2007-2009 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.17 2012/11/04 14:40:47 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.18 2013/03/10 16:51:31 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -48,6 +48,10 @@
struct lwp *mylwp;
};
+static bool threads_are_go;
+static struct rumpuser_mtx *thrmtx;
+static struct rumpuser_cv *thrcv;
+
static void *
threadbouncer(void *arg)
{
@@ -59,6 +63,15 @@
f = k->f;
thrarg = k->arg;
+ /* don't allow threads to run before all CPUs have fully attached */
+ if (!threads_are_go) {
+ rumpuser_mutex_enter_nowrap(thrmtx);
+ while (!threads_are_go) {
+ rumpuser_cv_wait_nowrap(thrcv, thrmtx);
+ }
+ rumpuser_mutex_exit(thrmtx);
+ }
+
/* schedule ourselves */
rumpuser_set_curlwp(l);
rump_schedule();
@@ -74,6 +87,25 @@
panic("unreachable, should kthread_exit()");
}
+void
+rump_thread_init(void)
+{
+
+ rumpuser_mutex_init(&thrmtx);
+ rumpuser_cv_init(&thrcv);
+}
+
+void
+rump_thread_allow(void)
+{
+
+ rumpuser_mutex_enter(thrmtx);
+ threads_are_go = true;
+ rumpuser_cv_broadcast(thrcv);
+ rumpuser_mutex_exit(thrmtx);
+
+}
+
static struct {
const char *t_name;
bool t_ncmp;
Home |
Main Index |
Thread Index |
Old Index