From d9da70c7c6230b9698dc4a1dbc4d7f05794d2740 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 3 Aug 2022 12:42:52 +0200 Subject: kernel: reuse a single allocation for all vfs_requests of a process $ iostress 32 512 0 > /vtty # before 512 calls, 0 bytes. avg 121133 $ iostress 32 512 0 > /vtty # after 512 calls, 0 bytes. avg 103540 103540/121133 = ~85% I think the tiny bit of added complexity is worth it here. --- src/kernel/proc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/kernel/proc.c') diff --git a/src/kernel/proc.c b/src/kernel/proc.c index a8cf303..e7a5ed6 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -114,8 +114,13 @@ void process_kill(struct process *p, int ret) { p->controlled = NULL; } - if (p->state == PS_WAITS4FS) - p->waits4fs.req->caller = NULL; + if (p->state == PS_WAITS4FS) { + assert(p->reqslot); + p->reqslot->caller = NULL; /* transfer ownership */ + p->reqslot = NULL; + } else if (p->reqslot) { + kfree(p->reqslot); + } if (p->state == PS_WAITS4PIPE) { struct process **iter = &p->waits4pipe.pipe->pipe.queued; -- cgit v1.2.3