1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:35:08 +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:
Gunnar Beutner 2021-04-25 23:42:36 +02:00 committed by Andreas Kling
parent f57c57966b
commit eb798d5538
26 changed files with 658 additions and 292 deletions

View file

@ -242,8 +242,14 @@ Process::~Process()
VERIFY(thread_count() == 0); // all threads should have been finalized
VERIFY(!m_alarm_timer);
if (g_profiling_all_threads) {
VERIFY(g_global_perf_events);
[[maybe_unused]] auto rc = g_global_perf_events->append_with_eip_and_ebp(
pid(), 0, 0, 0, PERF_EVENT_PROCESS_EXIT, 0, 0, nullptr);
}
{
ScopedSpinLock processses_lock(g_processes_lock);
ScopedSpinLock processes_lock(g_processes_lock);
if (prev() || next())
g_processes->remove(this);
}
@ -675,7 +681,7 @@ bool Process::create_perf_events_buffer_if_needed()
{
if (!m_perf_event_buffer) {
m_perf_event_buffer = PerformanceEventBuffer::try_create_with_size(4 * MiB);
m_perf_event_buffer->add_process(*this);
m_perf_event_buffer->add_process(*this, ProcessEventType::Create);
}
return !!m_perf_event_buffer;
}