[kernel] Store object ids instead of full koids

In preparation for futexes, I wanted to make kobjects a bit lighter.
Storing 32 bits of object id, and 8 bits of type (and not ending the
class in a ushort for handle count, which meant all kobjects were likely
to have a bunch of pad bytes), the kobject class data is now just one 8
byte word.

Also from this, change logs that mention threads or processes from
printing the full koid to just 2 bytes of object id from both process
and thread, which makes following the logs much easier.
This commit is contained in:
Justin C. Miller
2022-10-20 22:41:16 -07:00
parent 6583744532
commit 372bc1d2e6
5 changed files with 44 additions and 37 deletions

View File

@@ -13,7 +13,7 @@ j6_status_t
process_create(j6_handle_t *self)
{
process *p = construct_handle<process>(self);
log::info(logs::task, "Process %llx created", p->koid());
log::info(logs::task, "Process <%02lx> created", p->obj_id());
return j6_status_ok;
}
@@ -22,7 +22,7 @@ process_kill(process *self)
{
process &p = process::current();
log::info(logs::task, "Process %llx killed by process %llx", self->koid(), p.koid());
log::info(logs::task, "Process <%02lx> killed by process <%02lx>", self->obj_id(), p.obj_id());
self->exit(-1u);
return j6_status_ok;
@@ -32,7 +32,7 @@ j6_status_t
process_exit(int32_t status)
{
process &p = process::current();
log::info(logs::task, "Process %llx exiting with code %d", p.koid(), status);
log::info(logs::task, "Process <%02lx> exiting with code %d", p.obj_id(), status);
p.exit(status);

View File

@@ -24,7 +24,7 @@ j6_status_t
log(const char *message)
{
thread &th = thread::current();
log::info(logs::syscall, "Message[%llx]: %s", th.koid(), message);
log::info(logs::syscall, "Message <%02lx:%02lx>: %s", th.parent().obj_id(), th.obj_id(), message);
return j6_status_ok;
}
@@ -32,7 +32,7 @@ j6_status_t
noop()
{
thread &th = thread::current();
log::verbose(logs::syscall, "Thread %llx called noop syscall.", th.koid());
log::verbose(logs::syscall, "Thread <%02lx:%02lx> called noop syscall.", th.parent().obj_id(), th.koid());
return j6_status_ok;
}

View File

@@ -22,8 +22,8 @@ thread_create(j6_handle_t *self, process *proc, uintptr_t stack_top, uintptr_t e
*self = child->self_handle();
child->set_state(thread::state::ready);
log::verbose(logs::task, "Thread %llx:%llx spawned new thread %llx:%llx",
parent_pr.koid(), parent_th.koid(), proc->koid(), child->koid());
log::verbose(logs::task, "Thread <%02lx:%02lx> spawned new thread <%02lx:%02lx>",
parent_pr.obj_id(), parent_th.obj_id(), proc->obj_id(), child->obj_id());
return j6_status_ok;
}
@@ -31,7 +31,7 @@ thread_create(j6_handle_t *self, process *proc, uintptr_t stack_top, uintptr_t e
j6_status_t
thread_kill(thread *self)
{
log::verbose(logs::task, "Killing thread %llx", self->koid());
log::verbose(logs::task, "Killing thread <%02lx:%02lx>", self->parent().obj_id(), self->obj_id());
self->exit();
return j6_status_ok;
}
@@ -46,7 +46,7 @@ j6_status_t
thread_exit()
{
thread &th = thread::current();
log::verbose(logs::task, "Thread %llx exiting", th.koid());
log::verbose(logs::task, "Thread <%02lx:%02lx> exiting", th.parent().obj_id(), th.obj_id());
th.exit();
log::error(logs::task, "returned to exit syscall");
@@ -60,7 +60,7 @@ thread_sleep(uint64_t duration)
uint64_t til = clock::get().value() + duration;
log::verbose(logs::task, "Thread %llx sleeping until %llu", th.koid(), til);
log::verbose(logs::task, "Thread <%02lx:%02lx> sleeping until %llu", th.parent().obj_id(), th.obj_id(), til);
th.set_wake_timeout(til);
th.block();
return j6_status_ok;