kernel/vm: Overhaul swap cache commitments.
Before this commit, swap space was committed entirely orthogonally from memory commitments. This was not handled at all correctly when cutting areas (the area cutting logic tries to migrate commitments between caches, but in the case of swapping caches, it didn't, and couldn't, take the separate fCommittedSwapSize into account.) Even without that problem, totally separate swap and memory commitments caused other problems. For instance, suppose a setup with 4GB of RAM and 4GB of swap. Many caches are created, and all 4GB of swap gets reserved, but the caches with this swap reserved have no or few pages in them. Then, all 4GB of RAM gets used up. The page daemon runs, and looks for things to swap out, but it can't find anything because all our swappable caches with pages have no swap reservations, so all it can do is flush out cached pages, which just degrades performance. Or, consider what would happen if the 4GB of swap was released, but the 4GB of RAM was still in use, and then the kernel tried to allocate memory. It would get OOM errors, because none of the caches have swap commitments and so nothing can be written out. Under this new system, the specific swap space reservation only happens just before the page is first written out, so both these cases should be handled smoothly, and swap should be used in a much more sensible fashion overall. This change seems to be more in line with what other OSes do (Windows Task Manager's "Committed" clearly is RAM+swap, for instance.) The only potential downside to this change is that swappable caches may temporarily go over their commitment when reading or writing out pages to swap, before the page daemon has a chance to come by and free the page or the swap space. But as that is a temporary state and should always be resolved by the page daemon, I think it's probably an acceptable trade-off. Change-Id: I928f4b4cacbec26ed6315179476eaff1a7f626c8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10305 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
9be0e148a2
commit
90ac9e6538
@@ -26,12 +26,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Should only be used by vm internals
|
||||
// Should only be used by VM internals
|
||||
status_t vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite,
|
||||
bool isExecute, bool isUser, addr_t *newip);
|
||||
void vm_unreserve_memory(size_t bytes);
|
||||
status_t vm_try_reserve_memory(size_t bytes, int priority, bigtime_t timeout);
|
||||
|
||||
void vm_unreserve_memory_or_swap(size_t bytes);
|
||||
status_t vm_try_reserve_memory_or_swap(size_t bytes, int priority, bigtime_t timeout);
|
||||
|
||||
void vm_debug_init();
|
||||
status_t vm_daemon_init(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user