mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 12:15:09 +00:00
Kernel: Use a separate timer for profiling the system
This updates the profiling subsystem to use a separate timer to trigger CPU sampling. This timer has a higher resolution (1000Hz) and is independent from the scheduler. At a later time the resolution could even be made configurable with an argument for sys$profiling_enable() - but not today.
This commit is contained in:
parent
d6b3513aab
commit
8614d18956
5 changed files with 46 additions and 8 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Time/TimeManagement.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -34,6 +35,7 @@ KResultOr<int> Process::sys$profiling_enable(pid_t pid)
|
|||
PerformanceManager::add_process_created_event(process);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
TimeManagement::the().enable_profile_timer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,6 +50,7 @@ KResultOr<int> Process::sys$profiling_enable(pid_t pid)
|
|||
if (!process->create_perf_events_buffer_if_needed())
|
||||
return ENOMEM;
|
||||
process->set_profiling(true);
|
||||
TimeManagement::the().enable_profile_timer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -60,6 +63,7 @@ KResultOr<int> Process::sys$profiling_disable(pid_t pid)
|
|||
return EPERM;
|
||||
ScopedCritical critical;
|
||||
g_profiling_all_threads = false;
|
||||
TimeManagement::the().disable_profile_timer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,6 +75,7 @@ KResultOr<int> Process::sys$profiling_disable(pid_t pid)
|
|||
return EPERM;
|
||||
if (!process->is_profiling())
|
||||
return EINVAL;
|
||||
TimeManagement::the().disable_profile_timer();
|
||||
process->set_profiling(false);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue