summaryrefslogtreecommitdiff
path: root/Kernel/Coredump.cpp
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-08-23 21:21:20 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-31 16:28:47 +0200
commit5e11a512d60f9ff9b8714b8528ba72a25ec9c787 (patch)
tree608c7fea6447b3356d24ebd062f31941d93fb513 /Kernel/Coredump.cpp
parent32a03cffebd4ea8c29f5a4d95bbea7e69c7659f2 (diff)
downloadserenity-5e11a512d60f9ff9b8714b8528ba72a25ec9c787.zip
Kernel: Buffer an entire region when generating coredumps
This allows us to unlock the region tree lock early, to avoid keeping the lock while we are doing IO.
Diffstat (limited to 'Kernel/Coredump.cpp')
-rw-r--r--Kernel/Coredump.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/Coredump.cpp b/Kernel/Coredump.cpp
index b010881443..cc0e963c9b 100644
--- a/Kernel/Coredump.cpp
+++ b/Kernel/Coredump.cpp
@@ -220,6 +220,8 @@ ErrorOr<void> Coredump::write_regions()
if (region.access() == Memory::Region::Access::None)
continue;
+ auto buffer = TRY(KBuffer::try_create_with_size("Coredump Region Copy Buffer"sv, region.page_count() * PAGE_SIZE));
+
TRY(m_process->address_space().with([&](auto& space) -> ErrorOr<void> {
auto* real_region = space->region_tree().regions().find(region.vaddr().get());
@@ -244,11 +246,13 @@ ErrorOr<void> Coredump::write_regions()
// If the current page is not backed by a physical page, we zero it in the coredump file.
return UserOrKernelBuffer::for_kernel_buffer(zero_buffer);
}();
- TRY(m_description->write(src_buffer.value(), PAGE_SIZE));
+ TRY(src_buffer.value().read(buffer->bytes().slice(i * PAGE_SIZE, PAGE_SIZE)));
}
return {};
}));
+
+ TRY(m_description->write(UserOrKernelBuffer::for_kernel_buffer(buffer->data()), buffer->size()));
}
return {};