mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
ksm: unmerge is an origin of OOMs
Just as the swapoff system call allocates many pages of RAM to various processes, perhaps triggering OOM, so "echo 2 >/sys/kernel/mm/ksm/run" (unmerge) is liable to allocate many pages of RAM to various processes, perhaps triggering OOM; and each is normally run from a modest admin process (swapoff or shell), easily repeated until it succeeds. So treat unmerge_and_remove_all_rmap_items() in the same way that we treat try_to_unuse(): generalize PF_SWAPOFF to PF_OOM_ORIGIN, and bracket both with that, to ask the OOM killer to kill them first, to prevent them from spawning more and more OOM kills. Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Izik Eidus <[email protected]> Cc: Andrea Arcangeli <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
a913e182ab
commit
35451beecb
4 changed files with 6 additions and 4 deletions
2
mm/ksm.c
2
mm/ksm.c
|
|
@ -1557,7 +1557,9 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
|
|||
if (ksm_run != flags) {
|
||||
ksm_run = flags;
|
||||
if (flags & KSM_RUN_UNMERGE) {
|
||||
current->flags |= PF_OOM_ORIGIN;
|
||||
err = unmerge_and_remove_all_rmap_items();
|
||||
current->flags &= ~PF_OOM_ORIGIN;
|
||||
if (err) {
|
||||
ksm_run = KSM_RUN_STOP;
|
||||
count = err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue