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.
This commit is contained in:
waddlesplash
2019-08-02 22:18:56 -04:00
committed by Ryan Leavengood
parent 47df2afbf8
commit 6cb38c6319
+4 -7
View File
@@ -244,16 +244,13 @@ low_resource_manager(void*)
{ {
bigtime_t timeout = kLowResourceInterval; bigtime_t timeout = kLowResourceInterval;
while (true) { while (true) {
int32 state = low_resource_state_no_update(B_ALL_KERNEL_RESOURCES); acquire_sem_etc(sLowResourceWaitSem, 1, B_RELATIVE_TIMEOUT,
if (state != B_LOW_RESOURCE_CRITICAL) { timeout);
acquire_sem_etc(sLowResourceWaitSem, 1, B_RELATIVE_TIMEOUT,
timeout);
}
RecursiveLocker _(&sLowResourceLock); RecursiveLocker _(&sLowResourceLock);
compute_state(); 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 " TRACE(("low_resource_manager: state = %ld, %ld free pages, %lld free "
"memory, %lu free semaphores\n", state, vm_page_num_free_pages(), "memory, %lu free semaphores\n", state, vm_page_num_free_pages(),
@@ -265,7 +262,7 @@ low_resource_manager(void*)
call_handlers(sLowResources); call_handlers(sLowResources);
if (state == B_LOW_RESOURCE_WARNING) if (state >= B_LOW_RESOURCE_WARNING)
timeout = kWarnResourceInterval; timeout = kWarnResourceInterval;
else else
timeout = kLowResourceInterval; timeout = kLowResourceInterval;