From 6cb38c63195a275a7a65b4fb79499586ead07432 Mon Sep 17 00:00:00 2001 From: waddlesplash Date: Fri, 2 Aug 2019 21:59:24 -0400 Subject: [PATCH] low_resource_manager: Do not spin forever during critical low resource conditions. Since this thread has a very high priority, this causes the whole system to lock up, making recovery from such a critical condition even more impossible. Instead use the Warning-level timeout instead (0.3 seconds), and of course we will be notified via the semaphore if something occurs we should know about. --- src/system/kernel/low_resource_manager.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/system/kernel/low_resource_manager.cpp b/src/system/kernel/low_resource_manager.cpp index 55962db93d..87c49117e4 100644 --- a/src/system/kernel/low_resource_manager.cpp +++ b/src/system/kernel/low_resource_manager.cpp @@ -244,16 +244,13 @@ low_resource_manager(void*) { bigtime_t timeout = kLowResourceInterval; while (true) { - int32 state = low_resource_state_no_update(B_ALL_KERNEL_RESOURCES); - if (state != B_LOW_RESOURCE_CRITICAL) { - acquire_sem_etc(sLowResourceWaitSem, 1, B_RELATIVE_TIMEOUT, - timeout); - } + acquire_sem_etc(sLowResourceWaitSem, 1, B_RELATIVE_TIMEOUT, + timeout); RecursiveLocker _(&sLowResourceLock); compute_state(); - state = low_resource_state_no_update(B_ALL_KERNEL_RESOURCES); + int32 state = low_resource_state_no_update(B_ALL_KERNEL_RESOURCES); TRACE(("low_resource_manager: state = %ld, %ld free pages, %lld free " "memory, %lu free semaphores\n", state, vm_page_num_free_pages(), @@ -265,7 +262,7 @@ low_resource_manager(void*) call_handlers(sLowResources); - if (state == B_LOW_RESOURCE_WARNING) + if (state >= B_LOW_RESOURCE_WARNING) timeout = kWarnResourceInterval; else timeout = kLowResourceInterval;