From 473112b1541cf81fa3670e0d1cb6de1c4a3281de Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 16 Jul 2024 23:55:32 +0200 Subject: kernel: make kmalloc accept a numeric "tag" instead of a freeform description This will both let me save space in the allocation header, and make the debugprint more readable. --- src/kernel/syscalls.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 1e1cd2f..3fc09fa 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -38,7 +38,7 @@ long _sys_fork(int flags, hid_t __user *fs_front) { SYSCALL_RETURN(-EMFILE); } - h->backend = kzalloc(sizeof *h->backend, "user fs"); + h->backend = kzalloc(sizeof *h->backend, TagUserFs); h->backend->usehcnt = 1; /* handle */ h->backend->is_user = true; h->backend->user.provhcnt = 1; @@ -68,7 +68,7 @@ hid_t _sys_open(const char __user *path, long len, int flags) { /* Doesn't check for free handles. Another thread could use up all * handles in the meantime anyways, or free some up. */ - path_buf = kmalloc(len, "path opn"); + path_buf = kmalloc(len, TagOpenPath); if (pcpy_from(proc_cur, path_buf, path, len) < (size_t)len) { goto fail; } @@ -111,7 +111,7 @@ long _sys_mount(hid_t hid, const char __user *path, long len) { if (PATH_MAX < len) SYSCALL_RETURN(-1); - path_buf = kmalloc(len, "path mnt"); + path_buf = kmalloc(len, TagMountPath); if (pcpy_from(proc_cur, path_buf, path, len) < (size_t)len) { goto fail; } @@ -138,7 +138,7 @@ long _sys_mount(hid_t hid, const char __user *path, long len) { // append to mount list // TODO move to kernel/vfs/mount.c - mount = kmalloc(sizeof *mount, "user mnt"); + mount = kmalloc(sizeof *mount, TagMountUser); mount->prev = proc_cur->mount; mount->prefix = path_buf; mount->prefix_owned = true; @@ -463,9 +463,8 @@ long _sys_execbuf(void __user *ubuf, size_t len) { SYSCALL_RETURN(-1); if (proc_cur->execbuf.buf) SYSCALL_RETURN(-1); - // TODO consider supporting nesting execbufs - char *kbuf = kmalloc(len, "execbuf"); + char *kbuf = kmalloc(len, TagExecbuf); if (pcpy_from(proc_cur, kbuf, ubuf, len) < len) { kfree(kbuf); SYSCALL_RETURN(-1); -- cgit v1.2.3