[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190411014353.113252-2-surenb@google.com>
Date: Wed, 10 Apr 2019 18:43:52 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: akpm@...ux-foundation.org
Cc: mhocko@...e.com, rientjes@...gle.com, willy@...radead.org,
yuzhoujian@...ichuxing.com, jrdr.linux@...il.com, guro@...com,
hannes@...xchg.org, penguin-kernel@...ove.SAKURA.ne.jp,
ebiederm@...ssion.com, shakeelb@...gle.com, christian@...uner.io,
minchan@...nel.org, timmurray@...gle.com, dancol@...gle.com,
joel@...lfernandes.org, jannh@...gle.com, surenb@...gle.com,
linux-mm@...ck.org, lsf-pc@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, kernel-team@...roid.com
Subject: [RFC 1/2] mm: oom: expose expedite_reclaim to use oom_reaper outside
of oom_kill.c
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@...gle.com>
---
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
Powered by blists - more mailing lists