From 66b7a01d58083f7f8f4b75b181e044a9f79baf9e Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 19 May 2016 20:33:36 +0200 Subject: [PATCH] nova: show pd info during unresolvable faults Fixes #1977 --- repos/base-nova/src/core/include/pager.h | 3 ++ .../base-nova/src/core/include/platform_pd.h | 8 +++ .../src/core/include/platform_thread.h | 9 +++- repos/base-nova/src/core/include/util.h | 8 +-- repos/base-nova/src/core/pager.cc | 51 ++++++++++++------- repos/base-nova/src/core/platform_pd.cc | 4 +- repos/base-nova/src/core/platform_thread.cc | 8 +-- 7 files changed, 61 insertions(+), 30 deletions(-) diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h index 87958f1c5..e2052743e 100644 --- a/repos/base-nova/src/core/include/pager.h +++ b/repos/base-nova/src/core/include/pager.h @@ -156,6 +156,9 @@ namespace Genode { unsigned long badge() const { return _badge; } void reset_badge() { _badge = 0; } + const char * client_thread() const; + const char * client_pd() const; + virtual int pager(Ipc_pager &ps) = 0; /** diff --git a/repos/base-nova/src/core/include/platform_pd.h b/repos/base-nova/src/core/include/platform_pd.h index 2cdc8e496..24ead2097 100644 --- a/repos/base-nova/src/core/include/platform_pd.h +++ b/repos/base-nova/src/core/include/platform_pd.h @@ -34,6 +34,7 @@ namespace Genode { Native_capability _parent; int _thread_cnt; addr_t _pd_sel; + const char * _label; public: @@ -90,6 +91,13 @@ namespace Genode { static addr_t pd_core_sel() { return __core_pd_sel; } + /** + * Label of this protection domain + * + * \return name of this protection domain + */ + const char * name() const { return _label; } + /***************************** ** Address-space interface ** *****************************/ diff --git a/repos/base-nova/src/core/include/platform_thread.h b/repos/base-nova/src/core/include/platform_thread.h index 599ccab87..92a2c1324 100644 --- a/repos/base-nova/src/core/include/platform_thread.h +++ b/repos/base-nova/src/core/include/platform_thread.h @@ -146,7 +146,7 @@ namespace Genode { /** * Return identification of thread when faulting */ - unsigned long pager_object_badge() const; + unsigned long pager_object_badge() { return (unsigned long)this; } /** * Set the executing CPU for this thread @@ -161,7 +161,12 @@ namespace Genode { /** * Get thread name */ - const char *name() const { return "noname"; } + const char *name() const { return _name.string(); } + + /** + * Get pd name + */ + const char *pd_name() const; /** * Associate thread with protection domain diff --git a/repos/base-nova/src/core/include/util.h b/repos/base-nova/src/core/include/util.h index dc8dbca00..8575de895 100644 --- a/repos/base-nova/src/core/include/util.h +++ b/repos/base-nova/src/core/include/util.h @@ -20,6 +20,7 @@ /* base-internal includes */ #include +#include namespace Genode { @@ -39,11 +40,12 @@ namespace Genode { Region_map::State::Fault_type pf_type, unsigned long faulter_badge) { - printf("%s (%s pf_addr=%p pf_ip=%p from %02lx %s)\n", msg, + Platform_thread * faulter = reinterpret_cast(faulter_badge); + printf("%s (%s pf_addr=%p pf_ip=%p from %02lx '%s':'%s')\n", msg, pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", (void *)pf_addr, (void *)pf_ip, - faulter_badge, - faulter_badge ? reinterpret_cast(faulter_badge) : 0); + faulter_badge, faulter ? faulter->pd_name() : "unknown", + faulter ? faulter->name() : "unknown"); } diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index e54898b89..ebbf6ab0e 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -23,6 +23,7 @@ /* core-local includes */ #include +#include #include /* NOVA includes */ @@ -100,12 +101,14 @@ void Pager_object::_page_fault_handler(addr_t pager_obj) obj->_state_lock.unlock(); - char const * client = reinterpret_cast(obj->_badge); + const char * client_thread = obj->client_thread(); + const char * client_pd = obj->client_pd(); + /* region manager fault - to be handled */ if (ret == 1) { - PDBG("page fault, thread '%s', cpu %u, ip=%lx, fault address=0x%lx", - client, which_cpu(pager_thread), ipc_pager.fault_ip(), - ipc_pager.fault_addr()); + PDBG("page fault, pd '%s', thread '%s', cpu %u, ip=%lx, fault " + "address=0x%lx", client_pd, client_thread, which_cpu(pager_thread), + ipc_pager.fault_ip(), ipc_pager.fault_addr()); utcb->set_msg_word(0); utcb->mtd = 0; @@ -117,9 +120,10 @@ void Pager_object::_page_fault_handler(addr_t pager_obj) /* unhandled case */ obj->_state.mark_dead(); - PWRN("unresolvable page fault, thread '%s', cpu %u, ip=%lx, " - "fault address=0x%lx ret=%u", client, which_cpu(pager_thread), - ipc_pager.fault_ip(), ipc_pager.fault_addr(), ret); + PWRN("unresolvable page fault, pd '%s', thread '%s', cpu %u, ip=%lx, " + "fault address=0x%lx ret=%u", client_pd, client_thread, + which_cpu(pager_thread), ipc_pager.fault_ip(), ipc_pager.fault_addr(), + ret); Native_capability pager_cap = obj->Object_pool::Entry::cap(); revoke(pager_cap.dst()); @@ -159,9 +163,9 @@ void Pager_object::exception(uint8_t exit_id) /* nobody handles this exception - so thread will be stopped finally */ _state.mark_dead(); - char const * client = reinterpret_cast(_badge); - PWRN("unresolvable exception %u, thread '%s', cpu %u, ip=0x%lx, %s", - exit_id, client, which_cpu(pager_thread), fault_ip, + PWRN("unresolvable exception %u, pd '%s', thread '%s', cpu %u, " + "ip=0x%lx, %s", exit_id, client_pd(), client_thread(), + which_cpu(pager_thread), fault_ip, res == 0xFF ? "no signal handler" : (res == NOVA_OK ? "" : "recall failed")); @@ -638,8 +642,8 @@ uint8_t Pager_object::handle_oom(addr_t transfer_from, char const * src_pd, char const * src_thread, enum Pager_object::Policy policy) { - const char * dst_pd = "unknown"; - const char * dst_thread = reinterpret_cast(badge()); + const char * dst_pd = client_pd(); + const char * dst_thread = client_thread(); enum { QUOTA_TRANSFER_PAGES = 2 }; @@ -655,8 +659,8 @@ uint8_t Pager_object::handle_oom(addr_t transfer_from, /* request current kernel quota usage of source pd */ Nova::pd_ctrl_debug(transfer_from, limit_source, usage_source); - PINF("oom - '%s:%s' (%lu/%lu) - transfer %u pages from '%s:%s' (%lu/%lu)", - dst_pd, dst_thread, + PINF("oom - '%s':'%s' (%lu/%lu) - transfer %u pages from '%s':'%s' " + "(%lu/%lu)", dst_pd, dst_thread, usage_before, limit_before, QUOTA_TRANSFER_PAGES, src_pd, src_thread, usage_source, limit_source); } @@ -682,7 +686,7 @@ uint8_t Pager_object::handle_oom(addr_t transfer_from, } PWRN("kernel memory quota upgrade failed - trigger memory free up for " - "causing '%s:%s' - donator is '%s:%s', policy=%u", + "causing '%s':'%s' - donator is '%s':'%s', policy=%u", dst_pd, dst_thread, src_pd, src_thread, policy); /* if nothing helps try to revoke memory */ @@ -797,8 +801,8 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src, transfer_from = __core_pd_sel; else { /* delegation of items between different PDs */ - src_pd = "unknown"; - src_thread = reinterpret_cast(obj_src->badge()); + src_pd = obj_src->client_pd(); + src_thread = obj_src->client_thread(); transfer_from = obj_src->pd_sel(); } } @@ -842,6 +846,19 @@ addr_t Pager_object::get_oom_portal() } +const char * Pager_object::client_thread() const +{ + Platform_thread * client = reinterpret_cast(_badge); + return client ? client->name() : "unknown"; +} + + +const char * Pager_object::client_pd() const +{ + Platform_thread * client = reinterpret_cast(_badge); + return client ? client->pd_name() : "unknown"; +} + /********************** ** Pager activation ** **********************/ diff --git a/repos/base-nova/src/core/platform_pd.cc b/repos/base-nova/src/core/platform_pd.cc index 0ea4a4e44..6b7fe4ad4 100644 --- a/repos/base-nova/src/core/platform_pd.cc +++ b/repos/base-nova/src/core/platform_pd.cc @@ -46,9 +46,9 @@ void Platform_pd::assign_parent(Native_capability parent) } -Platform_pd::Platform_pd(Allocator * md_alloc, char const *, +Platform_pd::Platform_pd(Allocator * md_alloc, char const *label, signed pd_id, bool create) -: _thread_cnt(0), _pd_sel(Native_thread::INVALID_INDEX) { } +: _thread_cnt(0), _pd_sel(Native_thread::INVALID_INDEX), _label(label) { } Platform_pd::~Platform_pd() diff --git a/repos/base-nova/src/core/platform_thread.cc b/repos/base-nova/src/core/platform_thread.cc index 233bf4264..b3e7a2d32 100644 --- a/repos/base-nova/src/core/platform_thread.cc +++ b/repos/base-nova/src/core/platform_thread.cc @@ -298,12 +298,8 @@ void Platform_thread::single_step(bool on) _pager->single_step(on); } - -unsigned long Platform_thread::pager_object_badge() const -{ - return reinterpret_cast(_name.string()); -} - +const char * Platform_thread::pd_name() const { + return _pd ? _pd->name() : "unknown"; } Weak_ptr Platform_thread::address_space() {