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/Syscalls/profiling.cpp | |
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/Syscalls/profiling.cpp')
-rw-r--r-- | Kernel/Syscalls/profiling.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Syscalls/profiling.cpp b/Kernel/Syscalls/profiling.cpp index 81b8e4690d..0b29e4ae51 100644 --- a/Kernel/Syscalls/profiling.cpp +++ b/Kernel/Syscalls/profiling.cpp @@ -25,7 +25,7 @@ KResultOr<int> Process::sys$profiling_enable(pid_t pid, u64 event_mask) if (!is_superuser()) return EPERM; ScopedCritical critical; - g_profiling_event_mask = event_mask; + g_profiling_event_mask = PERF_EVENT_PROCESS_CREATE | PERF_EVENT_THREAD_CREATE | PERF_EVENT_MMAP; if (g_global_perf_events) g_global_perf_events->clear(); else @@ -40,6 +40,7 @@ KResultOr<int> Process::sys$profiling_enable(pid_t pid, u64 event_mask) PerformanceManager::add_process_created_event(process); return IterationDecision::Continue; }); + g_profiling_event_mask = event_mask; return 0; } @@ -51,12 +52,13 @@ KResultOr<int> Process::sys$profiling_enable(pid_t pid, u64 event_mask) return ESRCH; if (!is_superuser() && process->uid() != euid()) return EPERM; - g_profiling_event_mask = event_mask; + g_profiling_event_mask = PERF_EVENT_PROCESS_CREATE | PERF_EVENT_THREAD_CREATE | PERF_EVENT_MMAP; process->set_profiling(true); if (!process->create_perf_events_buffer_if_needed()) { process->set_profiling(false); return ENOMEM; } + g_profiling_event_mask = event_mask; if (!TimeManagement::the().enable_profile_timer()) { process->set_profiling(false); return ENOTSUP; |