瀏覽代碼

Kernel: Disable profiling during the critical section of sys$execve()

Since we're gonna throw away these stacks at the end of exec anyway,
we might as well disable profiling before starting to mess with the
process page tables. One less weird situation to worry about in the
sampling code.
Andreas Kling 5 年之前
父節點
當前提交
ece2971112
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      Kernel/Process.cpp

+ 5 - 1
Kernel/Process.cpp

@@ -804,6 +804,10 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
         return -ETXTBSY;
         return -ETXTBSY;
     }
     }
 
 
+    // Disable profiling temporarily in case it's running on this process.
+    bool was_profiling = is_profiling();
+    TemporaryChange profiling_disabler(m_profiling, false);
+
     auto old_page_directory = move(m_page_directory);
     auto old_page_directory = move(m_page_directory);
     auto old_regions = move(m_regions);
     auto old_regions = move(m_regions);
     m_page_directory = PageDirectory::create_for_userspace(*this);
     m_page_directory = PageDirectory::create_for_userspace(*this);
@@ -1015,7 +1019,7 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
     kprintf("Process %u (%s) exec'd %s @ %p\n", pid(), name().characters(), path.characters(), tss.eip);
     kprintf("Process %u (%s) exec'd %s @ %p\n", pid(), name().characters(), path.characters(), tss.eip);
 #endif
 #endif
 
 
-    if (is_profiling())
+    if (was_profiling)
         Profiling::did_exec(path);
         Profiling::did_exec(path);
 
 
     new_main_thread->set_state(Thread::State::Skip1SchedulerPass);
     new_main_thread->set_state(Thread::State::Skip1SchedulerPass);