From 83e44b4f5d02cfd5aad7d03ddb075f4b94bf35b9 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 11 Jun 2023 23:07:36 +0300 Subject: add some clarifications to rpc stack stuff --- common/uapi/ipc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'common/uapi/ipc.c') diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c index 1d48f71..9cbdce8 100644 --- a/common/uapi/ipc.c +++ b/common/uapi/ipc.c @@ -36,6 +36,11 @@ static void mark_rpc_inaccessible(struct tcb *t, vm_t start, vm_t end) */ static void mark_rpc_accessible(struct tcb *t, vm_t start, vm_t end) { + /** @todo this could still be optimized with arch-specific stuff I would + * imagine, as set_vpage_flags() has to traverse the whole tree for each + * page to mark. Instead it should be possible to mark the pages + * continuously once they've been traversed once. Or maybe even keep + * around a pointer to where the last stack left off? */ size_t page_size = BASE_PAGE_SIZE; size_t size = end - start; size_t pages = size / page_size; @@ -43,7 +48,7 @@ static void mark_rpc_accessible(struct tcb *t, vm_t start, vm_t end) set_vpage_flags(t->rpc.vmem, start + pages * page_size, VM_U); } -/** Structure for maintaingin the required context data for an rpc call. */ +/** Structure for maintaining the required context data for an rpc call. */ struct call_ctx { /** Execution continuation point. */ vm_t exec; @@ -189,10 +194,14 @@ static void leave_rpc(struct tcb *t, struct sys_ret a) */ static bool enough_rpc_stack(struct tcb *t) { + /* get top of call stack */ vm_t top = RPC_STACK_BASE + __call_stack_size; + /* get start of the next rpc stack instance */ vm_t rpc_stack = t->rpc_stack + BASE_PAGE_SIZE; - return top - rpc_stack >= __call_stack_size / RPC_STACK_RATIO; + /* if we can still fit an rpc stack into the call stack, we can safely + * do the migration. */ + return top - rpc_stack >= __rpc_stack_size; } /** -- cgit v1.3