summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-01-15 17:48:42 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-15 19:51:16 +0100
commit094b88e6a54dbc2cde11d558ae239eb8704c8898 (patch)
tree6bced1d83d5f412ff4cb25e9fae7b0537334e32d
parentc6adefcfc04c6e0a5bd85fa445da38975e5bd414 (diff)
downloadserenity-094b88e6a54dbc2cde11d558ae239eb8704c8898.zip
Kernel: Don't remap already non-writable regions when they become CoW
The only purpose of the remap() in Region::try_clone() is to ensure non-writable page table entries for CoW regions. If a region is already non-writable, there's no need to waste time updating the page tables.
-rw-r--r--Kernel/Memory/Region.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Kernel/Memory/Region.cpp b/Kernel/Memory/Region.cpp
index d69b2ef95a..b7c741ec19 100644
--- a/Kernel/Memory/Region.cpp
+++ b/Kernel/Memory/Region.cpp
@@ -94,7 +94,8 @@ ErrorOr<NonnullOwnPtr<Region>> Region::try_clone()
auto vmobject_clone = TRY(vmobject().try_clone());
// Set up a COW region. The parent (this) region becomes COW as well!
- remap();
+ if (is_writable())
+ remap();
OwnPtr<KString> clone_region_name;
if (m_name)