Просмотр исходного кода

Kernel: Use PrivateInodeVMObject for loading program executables

This will be a memory usage pessimization until we actually implement
CoW sharing of the memory pages with SharedInodeVMObject.

However, it's a huge architectural improvement, so let's take it and
improve on this incrementally.

fork() should still be neutral, since all private mappings are CoW'ed.
Andreas Kling 5 лет назад
Родитель
Сommit
e2697c2ddd
1 измененных файлов с 3 добавлено и 11 удалено
  1. 3 11
      Kernel/Process.cpp

+ 3 - 11
Kernel/Process.cpp

@@ -67,6 +67,7 @@
 #include <Kernel/TTY/TTY.h>
 #include <Kernel/TTY/TTY.h>
 #include <Kernel/Thread.h>
 #include <Kernel/Thread.h>
 #include <Kernel/VM/PageDirectory.h>
 #include <Kernel/VM/PageDirectory.h>
+#include <Kernel/VM/PrivateInodeVMObject.h>
 #include <Kernel/VM/PurgeableVMObject.h>
 #include <Kernel/VM/PurgeableVMObject.h>
 #include <Kernel/VM/SharedInodeVMObject.h>
 #include <Kernel/VM/SharedInodeVMObject.h>
 #include <LibBareMetal/IO.h>
 #include <LibBareMetal/IO.h>
@@ -808,17 +809,8 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
     if (parts.is_empty())
     if (parts.is_empty())
         return -ENOENT;
         return -ENOENT;
 
 
-    RefPtr<SharedInodeVMObject> vmobject;
-    if (interpreter_description) {
-        vmobject = SharedInodeVMObject::create_with_inode(*interpreter_description->inode());
-    } else {
-        vmobject = SharedInodeVMObject::create_with_inode(*main_program_description->inode());
-    }
-
-    if (static_cast<const SharedInodeVMObject&>(*vmobject).writable_mappings()) {
-        dbg() << "Refusing to execute a write-mapped program";
-        return -ETXTBSY;
-    }
+    auto& inode = interpreter_description ? *interpreter_description->inode() : *main_program_description->inode();
+    auto vmobject = PrivateInodeVMObject::create_with_inode(inode);
 
 
     // Disable profiling temporarily in case it's running on this process.
     // Disable profiling temporarily in case it's running on this process.
     bool was_profiling = is_profiling();
     bool was_profiling = is_profiling();