kernel: Notify low resource handler & retry when low on kernel address space.

Solves a decade-old TODO. This might help with strange behavior in
low-memory conditions.
This commit is contained in:
Augustin Cavalier
2018-12-11 14:44:52 -05:00
parent 0a347c90d5
commit f1e8678942
+9 -8
View File
@@ -871,16 +871,17 @@ map_backing_store(VMAddressSpace* addressSpace, VMCache* cache, off_t offset,
status = addressSpace->InsertArea(area, size, addressRestrictions, status = addressSpace->InsertArea(area, size, addressRestrictions,
allocationFlags, _virtualAddress); allocationFlags, _virtualAddress);
if (status != B_OK) { if (status == B_NO_MEMORY
// TODO: wait and try again once this is working in the backend && addressRestrictions->address_specification == B_ANY_KERNEL_ADDRESS) {
#if 0 // issue a low resource notification and try again
if (status == B_NO_MEMORY && addressSpec == B_ANY_KERNEL_ADDRESS) { low_resource(B_KERNEL_RESOURCE_ADDRESS_SPACE, size, B_RELATIVE_TIMEOUT,
low_resource(B_KERNEL_RESOURCE_ADDRESS_SPACE, size, ((flags & CREATE_AREA_DONT_WAIT) != 0) ? 0 : 100000 /* 100ms*/);
0, 0);
status = addressSpace->InsertArea(area, size, addressRestrictions,
allocationFlags, _virtualAddress);
} }
#endif if (status != B_OK)
goto err2; goto err2;
}
// attach the cache to the area // attach the cache to the area
area->cache = cache; area->cache = cache;