Use run_as_rkm() for simple functions
These were a few places where the kernel message trampoline was just a
wrapper around a single function. There are a bunch of places where
there is a separate function that does a bunch of things in the kmsg.
I'm fine with leaving them as-is for now.
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/src/kthread.c b/kern/src/kthread.c
index e1010ca..1457a3b 100644
--- a/kern/src/kthread.c
+++ b/kern/src/kthread.c
@@ -227,21 +227,13 @@
KMSG_ROUTINE);
}
-/* Kmsg helper for kthread_yield */
-static void __wake_me_up(uint32_t srcid, long a0, long a1, long a2)
-{
- struct semaphore *sem = (struct semaphore*)a0;
- assert(sem_up(sem));
-}
-
/* Stop the current kthread. It'll get woken up next time we run routine kmsgs,
* after all existing kmsgs are processed. */
void kthread_yield(void)
{
struct semaphore local_sem, *sem = &local_sem;
sem_init(sem, 0);
- send_kernel_message(core_id(), __wake_me_up, (long)sem, 0, 0,
- KMSG_ROUTINE);
+ run_as_rkm(sem_up, sem);
sem_down(sem);
}
diff --git a/kern/src/rcu.c b/kern/src/rcu.c
index 8481025..23a8a6c 100644
--- a/kern/src/rcu.c
+++ b/kern/src/rcu.c
@@ -160,19 +160,13 @@
head->func(head);
}
-static void __early_call_rcu_kmsg(uint32_t srcid, long a0, long a1, long a2)
-{
- rcu_exec_cb((struct rcu_head*)a0);
-}
-
void __early_call_rcu(struct rcu_head *head)
{
extern bool booting;
assert(booting);
assert(core_id() == 0);
- send_kernel_message(0, __early_call_rcu_kmsg, (long)head, 0, 0,
- KMSG_ROUTINE);
+ run_as_rkm(rcu_exec_cb, head);
}
/* This could be called from a remote core, e.g. rcu_barrier(). Returns the
diff --git a/kern/src/schedule.c b/kern/src/schedule.c
index 5823b03..4804885 100644
--- a/kern/src/schedule.c
+++ b/kern/src/schedule.c
@@ -79,12 +79,6 @@
set_alarm(&per_cpu_info[core_id()].tchain, &ksched_waiter);
}
-/* Need a kmsg to just run the sched, but not to rearm */
-static void __just_sched(uint32_t srcid, long a0, long a1, long a2)
-{
- run_scheduler();
-}
-
/* RKM alarm, to run the scheduler tick (not in interrupt context) and reset the
* alarm. Note that interrupts will be disabled, but this is not the same as
* interrupt context. We're a routine kmsg, which means the core is in a
@@ -301,8 +295,7 @@
/* process might be dying, with a KMSG to clean it up waiting on
* this core. can't do much, so we'll attempt to restart */
if (proc_is_dying(pcpui->owning_proc)) {
- send_kernel_message(core_id(), __just_sched, 0, 0, 0,
- KMSG_ROUTINE);
+ run_as_rkm(run_scheduler);
spin_unlock(&pcpui->owning_proc->proc_lock);
return FALSE;
}
diff --git a/kern/src/taskqueue.c b/kern/src/taskqueue.c
index e988409..0588afa 100644
--- a/kern/src/taskqueue.c
+++ b/kern/src/taskqueue.c
@@ -11,21 +11,12 @@
#include <kthread.h>
/* BSD Taskqueue wrappers. */
-static void __tq_wrapper(uint32_t srcid, long a0, long a1, long a2)
-{
- task_fn_t tq_fn = (task_fn_t)a0;
- void *tq_arg = (void*)a1;
- tq_fn(tq_arg, 0);
-}
-
int taskqueue_enqueue(struct taskqueue *queue, struct task *task)
{
- send_kernel_message(core_id(), __tq_wrapper, (long)task->ta_func,
- (long)task->ta_context, 0, KMSG_ROUTINE);
+ run_as_rkm(task->ta_func, task->ta_context, 0);
return 0;
}
-
/* Linux workqueue wrappers */
void flush_workqueue(struct workqueue_struct *wq)
{