diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-30 16:24:53 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-30 19:03:03 +0200 |
commit | 01c75e3a34c463230583ac7979164159ad8ed306 (patch) | |
tree | 39ffbd7b1264106023f970495dee51610b96163f /Kernel/Heap | |
parent | d24dd7a3dfdfda3ceb120c2a7172324edea6444f (diff) | |
download | serenity-01c75e3a34c463230583ac7979164159ad8ed306.zip |
Kernel: Don't log profile data before/after the process/thread lifetime
There were a few cases where we could end up logging profiling events
before or after the associated process or thread exists in the profile:
After enabling profiling we might end up with CPU samples before we
had a chance to synthesize process/thread creation events.
After a thread exits we would still log associated kmalloc/kfree
events. Instead we now just ignore those events.
Diffstat (limited to 'Kernel/Heap')
-rw-r--r-- | Kernel/Heap/kmalloc.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 5c245fc7a7..4562e82936 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -257,11 +257,11 @@ void* kmalloc(size_t size) PANIC("kmalloc: Out of memory (requested size: {})", size); } - Process* current_process = Process::current(); - if (!current_process && Scheduler::colonel_initialized()) - current_process = Scheduler::colonel(); - if (current_process) - PerformanceManager::add_kmalloc_perf_event(*current_process, size, (FlatPtr)ptr); + Thread* current_thread = Thread::current(); + if (!current_thread) + current_thread = Processor::idle_thread(); + if (current_thread) + PerformanceManager::add_kmalloc_perf_event(*current_thread, size, (FlatPtr)ptr); return ptr; } @@ -277,11 +277,11 @@ void kfree(void* ptr) ++g_nested_kfree_calls; if (g_nested_kfree_calls == 1) { - Process* current_process = Process::current(); - if (!current_process && Scheduler::colonel_initialized()) - current_process = Scheduler::colonel(); - if (current_process) - PerformanceManager::add_kfree_perf_event(*current_process, 0, (FlatPtr)ptr); + Thread* current_thread = Thread::current(); + if (!current_thread) + current_thread = Processor::idle_thread(); + if (current_thread) + PerformanceManager::add_kfree_perf_event(*current_thread, 0, (FlatPtr)ptr); } g_kmalloc_global->m_heap.deallocate(ptr); |