Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
ece2971112
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  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;
     }
 
+    // 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_regions = move(m_regions);
     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);
 #endif
 
-    if (is_profiling())
+    if (was_profiling)
         Profiling::did_exec(path);
 
     new_main_thread->set_state(Thread::State::Skip1SchedulerPass);