From: Suren Baghdasaryan <surenb@google.com>
To: akpm@linux-foundation.org
Cc: mhocko@suse.com, rientjes@google.com, willy@infradead.org,
yuzhoujian@didichuxing.com, jrdr.linux@gmail.com, guro@fb.com,
hannes@cmpxchg.org, penguin-kernel@I-love.SAKURA.ne.jp,
ebiederm@xmission.com, shakeelb@google.com, christian@brauner.io,
minchan@kernel.org, timmurray@google.com, dancol@google.com,
joel@joelfernandes.org, jannh@google.com, surenb@google.com,
linux-mm@kvack.org, lsf-pc@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: [RFC 1/2] mm: oom: expose expedite_reclaim to use oom_reaper outside of oom_kill.c
Date: Wed, 10 Apr 2019 18:43:52 -0700 [thread overview]
Message-ID: <20190411014353.113252-2-surenb@google.com> (raw)
In-Reply-To: <20190411014353.113252-1-surenb@google.com>
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@google.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
next prev parent reply other threads:[~2019-04-11 1:44 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 1:43 [RFC 0/2] opportunistic memory reclaim of a killed process Suren Baghdasaryan
2019-04-11 1:43 ` Suren Baghdasaryan [this message]
2019-04-25 21:12 ` [RFC 1/2] mm: oom: expose expedite_reclaim to use oom_reaper outside of oom_kill.c Tetsuo Handa
2019-04-25 21:56 ` Suren Baghdasaryan
2019-04-11 1:43 ` [RFC 2/2] signal: extend pidfd_send_signal() to allow expedited process killing Suren Baghdasaryan
2019-04-11 10:30 ` Christian Brauner
2019-04-11 10:34 ` Christian Brauner
2019-04-11 15:18 ` Suren Baghdasaryan
2019-04-11 15:23 ` Suren Baghdasaryan
2019-04-11 16:25 ` Daniel Colascione
2019-04-11 15:33 ` Matthew Wilcox
2019-04-11 17:05 ` Johannes Weiner
2019-04-11 17:09 ` Suren Baghdasaryan
2019-04-11 17:33 ` Daniel Colascione
2019-04-11 17:36 ` Matthew Wilcox
2019-04-11 17:47 ` Daniel Colascione
2019-04-12 6:49 ` Michal Hocko
2019-04-12 14:15 ` Suren Baghdasaryan
2019-04-12 14:20 ` Daniel Colascione
2019-04-12 21:03 ` Matthew Wilcox
2019-04-11 17:52 ` Suren Baghdasaryan
2019-04-11 21:45 ` Roman Gushchin
2019-04-11 21:59 ` Suren Baghdasaryan
2019-04-12 6:53 ` Michal Hocko
2019-04-12 14:10 ` Suren Baghdasaryan
2019-04-12 14:14 ` Daniel Colascione
2019-04-12 15:30 ` Daniel Colascione
2019-04-25 16:09 ` Suren Baghdasaryan
2019-04-11 10:51 ` [RFC 0/2] opportunistic memory reclaim of a killed process Michal Hocko
2019-04-11 16:18 ` Joel Fernandes
2019-04-11 18:12 ` Michal Hocko
2019-04-11 19:14 ` Joel Fernandes
2019-04-11 20:11 ` Michal Hocko
2019-04-11 21:11 ` Joel Fernandes
2019-04-11 16:20 ` Sandeep Patil
2019-04-11 16:47 ` Suren Baghdasaryan
2019-04-11 18:19 ` Michal Hocko
2019-04-11 19:56 ` Suren Baghdasaryan
2019-04-11 20:17 ` Michal Hocko
2019-04-11 17:19 ` Johannes Weiner
2019-04-11 11:51 ` [Lsf-pc] " Rik van Riel
2019-04-11 12:16 ` Michal Hocko
2019-04-11 16:54 ` Suren Baghdasaryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190411014353.113252-2-surenb@google.com \
--to=surenb@google.com \
--cc=akpm@linux-foundation.org \
--cc=christian@brauner.io \
--cc=dancol@google.com \
--cc=ebiederm@xmission.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=jannh@google.com \
--cc=joel@joelfernandes.org \
--cc=jrdr.linux@gmail.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
--cc=shakeelb@google.com \
--cc=timmurray@google.com \
--cc=willy@infradead.org \
--cc=yuzhoujian@didichuxing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).