diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-18 02:26:11 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-19 22:51:42 +0200 |
commit | 83fc591cea615c7c6efda62d92a08cb0dd932af0 (patch) | |
tree | 0b1de2dfe52104f4829252e048c1404f84a7ff75 /Kernel/Arch/i386 | |
parent | 6ac1ca5a9afbc900a483a1c528eb4b1c62a1c67e (diff) | |
download | serenity-83fc591cea615c7c6efda62d92a08cb0dd932af0.zip |
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>
Diffstat (limited to 'Kernel/Arch/i386')
-rw-r--r-- | Kernel/Arch/i386/CPU.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index be267ea97b..10b8136662 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -23,6 +23,7 @@ #include <Kernel/Interrupts/UnhandledInterruptHandler.h> #include <Kernel/KSyms.h> #include <Kernel/Panic.h> +#include <Kernel/PerformanceManager.h> #include <Kernel/Process.h> #include <Kernel/Random.h> #include <Kernel/Thread.h> @@ -243,8 +244,11 @@ void page_fault_handler(TrapFrame* trap) auto current_thread = Thread::current(); - if (current_thread) + if (current_thread) { current_thread->set_handling_page_fault(true); + PerformanceManager::add_page_fault_event(*current_thread, regs); + } + ScopeGuard guard = [current_thread] { if (current_thread) current_thread->set_handling_page_fault(false); |