forked from crdroidandroid/android_kernel_xiaomi_sm6150
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple_lmk: Reap anonymous memory from victims
The OOM reaper makes it possible to immediately release anonymous memory from a dying process in order to free up memory faster. This provides immediate relief under heavy memory pressure instead of waiting for victim processes to naturally release their memory. Utilize the OOM reaper by creating another kthread in Simple LMK to perform victim reaping. Similar to the OOM reaper kthread (which is unused with Simple LMK), this new kthread allows reaping to race with exit_mmap() in order to preclude the need to take a reference to an mm's address space and thus potentially mmput() an mm's last reference. Doing so would stall the reaper kthread, preventing it from being able to quickly reap new victims. Reaping is done on victims one at a time by descending order of anonymous pages, so that the most promising victims with the most anonymous pages are reaped first. Victims are also marked for reaping via MMF_OOM_VICTIM so that they reap themselves first in exit_mmap(). Even if a victim isn't reaped by the reaper thread, it'll free its anonymous memory first thing in exit_mmap() as a small win towards making memory available sooner. By relieving memory pressure faster via reaping, Simple LMK not only doesn't need to kill as many processes, but also improves system responsiveness when memory is low since memory pressure is relieved sooner. Although not strictly required, Simple LMK should be the only one utilizing the OOM reaper. Any other code that may utilize the OOM reaper, such as patches that invoke the OOM reaper for all SIGKILLs, should be disabled. Signed-off-by: Sultan Alsawaf <[email protected]>
- Loading branch information
1 parent
a6517ee
commit 429ae63
Showing
1 changed file
with
164 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters