mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Kernel: Move cpu sample perf event to PerformanceManager
This commit is contained in:
parent
d7089a0417
commit
7463cbdbdb
Notes:
sideshowbarker
2024-07-18 18:36:41 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/7463cbdbdb7 Pull-request: https://github.com/SerenityOS/serenity/pull/6909
@ -52,6 +52,29 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline static void add_cpu_sample_event(Thread& current_thread, const RegisterState& regs)
|
||||
{
|
||||
PerformanceEventBuffer* perf_events = nullptr;
|
||||
|
||||
if (g_profiling_all_threads) {
|
||||
VERIFY(g_global_perf_events);
|
||||
// FIXME: We currently don't collect samples while idle.
|
||||
// That will be an interesting mode to add in the future. :^)
|
||||
if (¤t_thread != Processor::current().idle_thread()) {
|
||||
perf_events = g_global_perf_events;
|
||||
}
|
||||
} else if (current_thread.process().is_profiling()) {
|
||||
VERIFY(current_thread.process().perf_events());
|
||||
perf_events = current_thread.process().perf_events();
|
||||
}
|
||||
|
||||
if (perf_events) {
|
||||
[[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);
|
||||
}
|
||||
}
|
||||
|
||||
inline static void add_mmap_perf_event(Process& current_process, Region const& region)
|
||||
{
|
||||
if (auto* event_buffer = current_process.current_perf_events_buffer()) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Panic.h>
|
||||
#include <Kernel/PerformanceEventBuffer.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/RTC.h>
|
||||
#include <Kernel/Scheduler.h>
|
||||
@ -501,25 +501,7 @@ void Scheduler::timer_tick(const RegisterState& regs)
|
||||
return; // TODO: This prevents scheduling on other CPUs!
|
||||
#endif
|
||||
|
||||
PerformanceEventBuffer* perf_events = nullptr;
|
||||
|
||||
if (g_profiling_all_threads) {
|
||||
VERIFY(g_global_perf_events);
|
||||
// FIXME: We currently don't collect samples while idle.
|
||||
// That will be an interesting mode to add in the future. :^)
|
||||
if (current_thread != Processor::current().idle_thread()) {
|
||||
perf_events = g_global_perf_events;
|
||||
}
|
||||
} else if (current_thread->process().is_profiling()) {
|
||||
VERIFY(current_thread->process().perf_events());
|
||||
perf_events = current_thread->process().perf_events();
|
||||
}
|
||||
|
||||
if (perf_events) {
|
||||
[[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);
|
||||
}
|
||||
PerformanceManager::add_cpu_sample_event(*current_thread, regs);
|
||||
|
||||
if (current_thread->tick())
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user