summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-02-20 20:46:37 +0100
committerRichard Braun <rbraun@sceen.net>2018-02-20 20:46:37 +0100
commitda8eb9c244d27fd042adde6234ccec079681d7f4 (patch)
treef0de4b67e3a59dded6598efe3db87c835da72b92 /kern/thread.c
parented9ada07d9c841b3f3f3a3f841aae2792a30779a (diff)
parent22dff6b7a6839e77d713d671cb2038e56b64ac16 (diff)
Merge branch 'preemptible_rcu'
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/kern/thread.c b/kern/thread.c
index 20378ffb..8460f3bc 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -101,6 +101,7 @@
#include <kern/macros.h>
#include <kern/panic.h>
#include <kern/percpu.h>
+#include <kern/rcu.h>
#include <kern/shell.h>
#include <kern/sleepq.h>
#include <kern/spinlock.h>
@@ -641,6 +642,8 @@ thread_runq_schedule(struct thread_runq *runq)
assert(next->preempt_level == THREAD_SUSPEND_PREEMPT_LEVEL);
if (likely(prev != next)) {
+ rcu_report_context_switch(thread_rcu_reader(prev));
+
/*
* That's where the true context switch occurs. The next thread must
* unlock the run queue and reenable preemption. Note that unlocking
@@ -1700,6 +1703,7 @@ thread_init_booter(unsigned int cpu)
booter->flags = 0;
booter->intr_level = 0;
booter->preempt_level = 1;
+ rcu_reader_init(&booter->rcu_reader);
cpumap_fill(&booter->cpumap);
thread_set_user_sched_policy(booter, THREAD_SCHED_POLICY_IDLE);
thread_set_user_sched_class(booter, THREAD_SCHED_CLASS_IDLE);
@@ -1828,6 +1832,7 @@ thread_init(struct thread *thread, void *stack,
thread->pin_level = 0;
thread->intr_level = 0;
thread->llsync_level = 0;
+ rcu_reader_init(&thread->rcu_reader);
cpumap_copy(&thread->cpumap, cpumap);
thread_set_user_sched_policy(thread, attr->policy);
thread_set_user_sched_class(thread, thread_policy_to_class(attr->policy));
@@ -2108,7 +2113,6 @@ static void
thread_idle(void *arg)
{
struct thread *self;
- int error;
(void)arg;
@@ -2116,13 +2120,6 @@ thread_idle(void *arg)
for (;;) {
thread_preempt_disable();
- error = sref_unregister();
-
- if (error) {
- assert(error == ERROR_BUSY);
- goto error_sref;
- }
-
llsync_unregister();
for (;;) {
@@ -2137,9 +2134,6 @@ thread_idle(void *arg)
}
llsync_register();
- sref_register();
-
-error_sref:
thread_preempt_enable();
}
}