소스 검색

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
```
Brian Gianforcaro 4 년 전
부모
커밋
afe099388e
3개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 0
      Kernel/CommandLine.cpp
  2. 1 0
      Kernel/CommandLine.h
  3. 7 1
      Kernel/init.cpp

+ 5 - 0
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");

+ 1 - 0
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;

+ 7 - 1
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);