aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-11-01 12:08:38 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-01 12:48:04 +0200
commita126211922d817cd1c4636c26d4a9a8b1b5f381f (patch)
treee930b224af3cc5f572f289488b7a87b03d6bf96e
parent83ec75327c1ec35f25b6aee24f616a41858be539 (diff)
downloadkmi-a126211922d817cd1c4636c26d4a9a8b1b5f381f.tar.gz
kmi-a126211922d817cd1c4636c26d4a9a8b1b5f381f.zip
copy rpc stacks directly
+ Speeds up fork a little bit
-rw-r--r--arch/riscv64/kernel/vmem.c18
-rw-r--r--src/uapi/ipc.c4
2 files changed, 7 insertions, 15 deletions
diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c
index 4556593..a215208 100644
--- a/arch/riscv64/kernel/vmem.c
+++ b/arch/riscv64/kernel/vmem.c
@@ -581,21 +581,13 @@ size_t max_rpc_size()
void copy_rpc_stack(struct tcb *t, struct tcb *c)
{
- /* this is of terrible, copying 2MiB for every fork, not
- * great. TODO: use the direct pointer to the rpc stack element? */
- for (size_t i = 0; i < rpc_pages; ++i) {
- pm_t p1, p2;
- stat_t ok1 = stat_vpage(t->rpc.vmem,
- RPC_STACK_BASE + BASE_PAGE_SIZE * i,
- &p1, NULL, NULL);
+ pm_t *pte1 = (pm_t *)t->arch.rpc_leaf;
+ pm_t page1 = (pm_t)pte_addr(*pte1);
- stat_t ok2 = stat_vpage(c->rpc.vmem,
- RPC_STACK_BASE + BASE_PAGE_SIZE * i,
- &p2, NULL, NULL);
+ pm_t *pte2 = (pm_t *)c->arch.rpc_leaf;
+ pm_t page2 = (pm_t)pte_addr(*pte2);
- assert(ok1 == OK && ok2 == OK);
- memcpy((void *)p2, (void *)p1, BASE_PAGE_SIZE);
- }
+ memcpy((void *)page2, (void *)page1, order_size(MM_O1));
}
stat_t setup_rpc_stack(struct tcb *t)
diff --git a/src/uapi/ipc.c b/src/uapi/ipc.c
index 644abc2..cebea68 100644
--- a/src/uapi/ipc.c
+++ b/src/uapi/ipc.c
@@ -48,7 +48,7 @@ enum ipc_flags {
static inline void finalize_rpc(struct tcb *t, struct tcb *r, vm_t s)
{
clone_uvmem(r->proc.vmem, t->rpc.vmem);
- flush_tlb_all();
+ flush_tlb_full();
set_return(t, r->callback);
reference_thread(r);
@@ -247,7 +247,7 @@ static void leave_rpc(struct tcb *t, struct sys_ret a)
* no-op */
t->rpc_stack = ctx->rpc_stack;
destroy_rpc(t);
- flush_tlb_all();
+ flush_tlb_full();
t->pid = ctx->pid;
t->eid = ctx->eid;