mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 19:38:12 +00:00
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.
This commit is contained in:
parent
f57c57966b
commit
eb798d5538
26 changed files with 658 additions and 292 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue