summaryrefslogtreecommitdiff
path: root/Kernel/Scheduler.cpp
diff options
context:
space:
mode:
authorGunnar Beutner <gunnar@beutner.name>2021-04-25 23:42:36 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-26 17:13:55 +0200
commiteb798d5538ea3c978034d8d8364ecfd7fbc6a8ee (patch)
treee023bc175ec5e7d89898f5214701e6d50154b75f /Kernel/Scheduler.cpp
parentf57c57966bb560a7090f4da528e5486d4c4de3f6 (diff)
downloadserenity-eb798d5538ea3c978034d8d8364ecfd7fbc6a8ee.zip
Kernel+Profiler: Improve profiling subsystem
This turns the perfcore format into more a log than it was before, which lets us properly log process, thread and region creation/destruction. This also makes it unnecessary to dump the process' regions every time it is scheduled like we did before. Incidentally this also fixes 'profile -c' because we previously ended up incorrectly dumping the parent's region map into the profile data. Log-based mmap support enables profiling shared libraries which are loaded at runtime, e.g. via dlopen(). This enables profiling both the parent and child process for programs which use execve(). Previously we'd discard the profiling data for the old process. The Profiler tool has been updated to not treat thread IDs as process IDs anymore. This enables support for processes with more than one thread. Also, there's a new widget to filter which process should be displayed.
Diffstat (limited to 'Kernel/Scheduler.cpp')
-rw-r--r--Kernel/Scheduler.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index c1e6f50f4a..4c90294ecc 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -22,9 +22,6 @@
namespace Kernel {
-extern bool g_profiling_all_threads;
-extern PerformanceEventBuffer* g_global_perf_events;
-
class SchedulerPerProcessorData {
AK_MAKE_NONCOPYABLE(SchedulerPerProcessorData);
AK_MAKE_NONMOVABLE(SchedulerPerProcessorData);
@@ -513,12 +510,6 @@ void Scheduler::timer_tick(const RegisterState& regs)
// That will be an interesting mode to add in the future. :^)
if (current_thread != Processor::current().idle_thread()) {
perf_events = g_global_perf_events;
- if (current_thread->process().space().enforces_syscall_regions()) {
- // FIXME: This is very nasty! We dump the current process's address
- // space layout *every time* it's sampled. We should figure out
- // a way to do this less often.
- perf_events->add_process(current_thread->process());
- }
}
} else if (current_thread->process().is_profiling()) {
VERIFY(current_thread->process().perf_events());
@@ -526,7 +517,9 @@ void Scheduler::timer_tick(const RegisterState& regs)
}
if (perf_events) {
- [[maybe_unused]] auto rc = perf_events->append_with_eip_and_ebp(regs.eip, regs.ebp, PERF_EVENT_SAMPLE, 0, 0);
+ [[maybe_unused]] auto rc = perf_events->append_with_eip_and_ebp(
+ current_thread->pid(), current_thread->tid(),
+ regs.eip, regs.ebp, PERF_EVENT_SAMPLE, 0, 0, nullptr);
}
if (current_thread->tick())