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.
This commit is contained in:
Tim Schumacher 2022-08-23 21:21:20 +02:00 committed by Andreas Kling
parent 32a03cffeb
commit 5e11a512d6
Notes: sideshowbarker 2024-07-17 07:35:59 +09:00

View file

@ -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 {};