1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

Kernel: Generate page fault events from the kernel profiler

Hook the kernel page fault handler and capture page fault events when
the fault has a current thread attached in TLS. We capture the eip and
ebp so we can unwind the stack and locate which pieces of code are
generating the most page faults.

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
This commit is contained in:
Brian Gianforcaro 2021-05-18 02:26:11 -07:00 committed by Andreas Kling
parent 6ac1ca5a9a
commit 83fc591cea
7 changed files with 47 additions and 2 deletions

View file

@ -106,6 +106,15 @@ public:
}
}
inline static void add_page_fault_event(Thread& thread, const RegisterState& regs)
{
if (auto* event_buffer = thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append_with_eip_and_ebp(
thread.pid(), thread.tid(),
regs.eip, regs.ebp, PERF_EVENT_PAGE_FAULT, 0, 0, 0, nullptr);
}
}
inline static void timer_tick(RegisterState const& regs)
{
static Time last_wakeup;