summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Gianforcaro <b.gianfo@gmail.com>2021-03-03 01:00:41 -0800
committerAndreas Kling <kling@serenityos.org>2021-03-03 11:05:16 +0100
commitafe099388e02f6e5a63e20d4bb6d51c62d2ad039 (patch)
treedd6593a44497420d621d873bb854b0e40b0e2af6
parent0f424afd5aae5d14c1783fac964ac5e9a5aeecc2 (diff)
downloadserenity-afe099388e02f6e5a63e20d4bb6d51c62d2ad039.zip
Kernel: Add 'boot_prof' option to enable full system profiling on boot
The full system profiling functionality is useful for profiling the boot performance of the system. Add a new kernel boot option to start the system with profiling enabled. This lets you disable and view a profile once the system is booted. You can use it by running: ``` $ run.sh qcmd boot_prof ```
-rw-r--r--Kernel/CommandLine.cpp5
-rw-r--r--Kernel/CommandLine.h1
-rw-r--r--Kernel/init.cpp8
3 files changed, 13 insertions, 1 deletions
diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp
index 005cd6080f..fdb09c4d41 100644
--- a/Kernel/CommandLine.cpp
+++ b/Kernel/CommandLine.cpp
@@ -88,6 +88,11 @@ bool CommandLine::contains(const String& key) const
return m_params.contains(key);
}
+UNMAP_AFTER_INIT bool CommandLine::is_boot_profiling_enabled() const
+{
+ return contains("boot_prof");
+}
+
UNMAP_AFTER_INIT bool CommandLine::is_ide_enabled() const
{
return !contains("disable_ide");
diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h
index 0e15bb70a8..75a236bbcd 100644
--- a/Kernel/CommandLine.h
+++ b/Kernel/CommandLine.h
@@ -61,6 +61,7 @@ public:
Optional<String> lookup(const String& key) const;
[[nodiscard]] bool contains(const String& key) const;
+ [[nodiscard]] bool is_boot_profiling_enabled() const;
[[nodiscard]] bool is_ide_enabled() const;
[[nodiscard]] bool is_smp_enabled() const;
[[nodiscard]] bool is_vmmouse_enabled() const;
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 5c13864361..5e21279d2e 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -246,7 +246,7 @@ void init_stage2(void*)
FinalizerTask::spawn();
PCI::initialize();
-
+ auto boot_profiling = kernel_command_line().is_boot_profiling_enabled();
auto is_text_mode = kernel_command_line().is_text_mode();
if (is_text_mode) {
dbgln("Text mode enabled");
@@ -319,6 +319,12 @@ void init_stage2(void*)
}
thread->set_priority(THREAD_PRIORITY_HIGH);
+ if (boot_profiling) {
+ dbgln("Starting full system boot profiling");
+ auto result = Process::current()->sys$profiling_enable(-1);
+ VERIFY(!result.is_error());
+ }
+
NetworkTask::spawn();
Process::current()->sys$exit(0);