Create an API to allow users outside of oom_kill.c to mark a victim and wake up oom_reaper thread for expedited memory reclaim of the process being killed. Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> --- include/linux/oom.h | 1 + mm/oom_kill.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/oom.h b/include/linux/oom.h index d07992009265..6c043c7518c1 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -112,6 +112,7 @@ extern unsigned long oom_badness(struct task_struct *p, unsigned long totalpages); extern bool out_of_memory(struct oom_control *oc); +extern bool expedite_reclaim(struct task_struct *task); extern void exit_oom_victim(void); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3a2484884cfd..6449710c8a06 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1102,6 +1102,21 @@ bool out_of_memory(struct oom_control *oc) return !!oc->chosen; } +bool expedite_reclaim(struct task_struct *task) +{ + bool res = false; + + task_lock(task); + if (task_will_free_mem(task)) { + mark_oom_victim(task); + wake_oom_reaper(task); + res = true; + } + task_unlock(task); + + return res; +} + /* * The pagefault handler calls here because it is out of memory, so kill a * memory-hogging task. If oom_lock is held by somebody else, a parallel oom -- 2.21.0.392.gf8f6787159e-goog