[kernel] Add spam logging to trace mailbox calls
Added a new IPC log category, and logging of mailbox calls in it. Also added some logs in init's service locator to help track down the bug fixed in the previous commit.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <util/counted.h>
|
||||
#include <j6/memutils.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include "objects/mailbox.h"
|
||||
#include "objects/thread.h"
|
||||
|
||||
@@ -26,6 +27,8 @@ mailbox::close()
|
||||
bool was_closed = __atomic_exchange_n(&m_closed, true, __ATOMIC_ACQ_REL);
|
||||
if (was_closed) return;
|
||||
|
||||
log::spam(logs::ipc, "mbx[%2x] closing...", obj_id());
|
||||
|
||||
m_callers.clear(j6_status_closed);
|
||||
m_responders.clear(j6_status_closed);
|
||||
|
||||
@@ -44,8 +47,14 @@ mailbox::call()
|
||||
m_callers.add_thread(¤t);
|
||||
|
||||
thread *responder = m_responders.pop_next();
|
||||
if (responder)
|
||||
if (responder) {
|
||||
log::spam(logs::ipc, "thread[%2x]:: mbx[%2x] call() waking thread[%2x]...",
|
||||
current.obj_id(), obj_id(), responder->obj_id());
|
||||
responder->wake(j6_status_ok);
|
||||
} else {
|
||||
log::spam(logs::ipc, "thread[%2x]:: mbx[%2x] call() found no responder yet.",
|
||||
current.obj_id(), obj_id());
|
||||
}
|
||||
|
||||
return current.block();
|
||||
}
|
||||
@@ -59,6 +68,7 @@ mailbox::receive(ipc::message &data, reply_tag_t &reply_tag, bool block)
|
||||
thread ¤t = thread::current();
|
||||
thread *caller = nullptr;
|
||||
|
||||
|
||||
while (true) {
|
||||
caller = m_callers.pop_next();
|
||||
if (caller)
|
||||
@@ -67,17 +77,24 @@ mailbox::receive(ipc::message &data, reply_tag_t &reply_tag, bool block)
|
||||
if (!block)
|
||||
return j6_status_would_block;
|
||||
|
||||
log::spam(logs::ipc, "thread[%2x]:: mbx[%2x] receive() blocking waiting for a caller",
|
||||
current.obj_id(), obj_id());
|
||||
|
||||
m_responders.add_thread(¤t);
|
||||
j6_status_t s = current.block();
|
||||
if (s != j6_status_ok)
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
util::scoped_lock lock {m_reply_lock};
|
||||
reply_tag = ++m_next_reply_tag;
|
||||
m_reply_map.insert({ reply_tag, caller });
|
||||
lock.release();
|
||||
|
||||
log::spam(logs::ipc, "thread[%2x]:: mbx[%2x] receive() found caller thread[%2x], rt = %x",
|
||||
current.obj_id(), obj_id(), caller->obj_id(), reply_tag);
|
||||
|
||||
data = caller->get_message_data();
|
||||
return j6_status_ok;
|
||||
}
|
||||
@@ -97,6 +114,10 @@ mailbox::reply(reply_tag_t reply_tag, ipc::message &&data)
|
||||
m_reply_map.erase(reply_tag);
|
||||
lock.release();
|
||||
|
||||
thread ¤t = thread::current();
|
||||
log::spam(logs::ipc, "thread[%2x]:: mbx[%2x] reply() to caller thread[%2x], rt = %x",
|
||||
current.obj_id(), obj_id(), caller->obj_id(), reply_tag);
|
||||
|
||||
caller->set_message_data(util::move(data));
|
||||
caller->wake(j6_status_ok);
|
||||
return j6_status_ok;
|
||||
|
||||
Reference in New Issue
Block a user