aboutsummaryrefslogtreecommitdiff
path: root/common/uapi
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-10-09 16:13:47 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-10-09 16:15:06 +0300
commit363d0ec55f1d7e0d44f14cb1d63fdca4bc72efde (patch)
tree122617be8859396dfd067e0da2cca4d8f670c277 /common/uapi
parent9c9d589ea310f1290e4d6d2019fc8b51d9a86e42 (diff)
downloadkmi-363d0ec55f1d7e0d44f14cb1d63fdca4bc72efde.tar.gz
kmi-363d0ec55f1d7e0d44f14cb1d63fdca4bc72efde.zip
experimenting with removing lists threads per proc
+ Gives a very slight improvement to RPC speeds, but mostly cleans up code a little bit.
Diffstat (limited to 'common/uapi')
-rw-r--r--common/uapi/ipc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c
index 13682c7..b9a435b 100644
--- a/common/uapi/ipc.c
+++ b/common/uapi/ipc.c
@@ -54,13 +54,13 @@ enum ipc_kind {
*
* @param t Thread to migrate.
* @param r Process to migrate to.
- * @param sd RPC stack regions to mark inaccessible.
+ * @param s RPC stack regions to mark inaccessible.
*/
static void finalize_rpc(struct tcb *t, struct tcb *r, vm_t s)
{
clone_uvmem(r->proc.vmem, t->rpc.vmem);
set_return(t, r->callback);
- attach_rpc(r, t);
+ reference_proc(r);
t->pid = r->rid;
/* make sure updates are visible when swapping to the new virtual memory */
@@ -135,6 +135,7 @@ static void leave_rpc(struct tcb *t, struct sys_ret a)
while (ctx->kick) {
rpc_stack = ctx->rpc_stack + BASE_PAGE_SIZE;
ctx = (struct call_ctx *)(rpc_stack) - 1;
+ unreference_proc(get_tcb(ctx->pid));
}
t->regs = ctx->regs;
@@ -224,6 +225,10 @@ static void do_ipc(struct tcb *t,
}
r = get_rproc(r);
+ if (unlikely(r->dead)) {
+ leave_rpc(t, SYS_RET1(ERR_INVAL));
+ return;
+ }
if (unlikely(!r->callback)) {
leave_rpc(t, SYS_RET1(ERR_NOINIT));
@@ -310,10 +315,7 @@ SYSCALL_DEFINE4(ipc_resp)(struct tcb *t, sys_arg_t d0, sys_arg_t d1,
if (unlikely(!is_rpc(t)))
return_args1(t, ERR_MISC);
- /* we need the current proc before leaving the rpc */
- struct tcb *r = get_cproc(t);
leave_rpc(t, SYS_RET6(OK, t->tid, d0, d1, d2, d3));
- detach_rpc(r, t);
}
/**