summaryrefslogtreecommitdiff
path: root/Kernel/Memory
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-08-27 19:00:57 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2022-08-27 21:54:13 +0300
commit12300b7d0b1b3735bb1c413ee5d8ac22163ac385 (patch)
tree1ef9dd1a089291333ce90f47ee16474eef8ec9cf /Kernel/Memory
parent4ce326205ecff513e09b104e36935726d6ad422d (diff)
downloadserenity-12300b7d0b1b3735bb1c413ee5d8ac22163ac385.zip
Kernel: Dump OOM debug info after releasing the MM global data lock
Otherwise we would be holding the MM global data lock and the Process address space locks in reversed order to the rest of the system, which can lead to deadlocks.
Diffstat (limited to 'Kernel/Memory')
-rw-r--r--Kernel/Memory/MemoryManager.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp
index 5d108e26bf..4db696a92e 100644
--- a/Kernel/Memory/MemoryManager.cpp
+++ b/Kernel/Memory/MemoryManager.cpp
@@ -829,28 +829,9 @@ ErrorOr<NonnullOwnPtr<Region>> MemoryManager::allocate_kernel_region_with_vmobje
ErrorOr<CommittedPhysicalPageSet> MemoryManager::commit_physical_pages(size_t page_count)
{
VERIFY(page_count > 0);
- return m_global_data.with([&](auto& global_data) -> ErrorOr<CommittedPhysicalPageSet> {
+ auto result = m_global_data.with([&](auto& global_data) -> ErrorOr<CommittedPhysicalPageSet> {
if (global_data.system_memory_info.physical_pages_uncommitted < page_count) {
dbgln("MM: Unable to commit {} pages, have only {}", page_count, global_data.system_memory_info.physical_pages_uncommitted);
-
- Process::for_each([&](Process const& process) {
- size_t amount_resident = 0;
- size_t amount_shared = 0;
- size_t amount_virtual = 0;
- process.address_space().with([&](auto& space) {
- amount_resident = space->amount_resident();
- amount_shared = space->amount_shared();
- amount_virtual = space->amount_virtual();
- });
- dbgln("{}({}) resident:{}, shared:{}, virtual:{}",
- process.name(),
- process.pid(),
- amount_resident / PAGE_SIZE,
- amount_shared / PAGE_SIZE,
- amount_virtual / PAGE_SIZE);
- return IterationDecision::Continue;
- });
-
return ENOMEM;
}
@@ -858,6 +839,26 @@ ErrorOr<CommittedPhysicalPageSet> MemoryManager::commit_physical_pages(size_t pa
global_data.system_memory_info.physical_pages_committed += page_count;
return CommittedPhysicalPageSet { {}, page_count };
});
+ if (result.is_error()) {
+ Process::for_each([&](Process const& process) {
+ size_t amount_resident = 0;
+ size_t amount_shared = 0;
+ size_t amount_virtual = 0;
+ process.address_space().with([&](auto& space) {
+ amount_resident = space->amount_resident();
+ amount_shared = space->amount_shared();
+ amount_virtual = space->amount_virtual();
+ });
+ dbgln("{}({}) resident:{}, shared:{}, virtual:{}",
+ process.name(),
+ process.pid(),
+ amount_resident / PAGE_SIZE,
+ amount_shared / PAGE_SIZE,
+ amount_virtual / PAGE_SIZE);
+ return IterationDecision::Continue;
+ });
+ }
+ return result;
}
void MemoryManager::uncommit_physical_pages(Badge<CommittedPhysicalPageSet>, size_t page_count)