summaryrefslogtreecommitdiffstats
path: root/include/linux/oom.h
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@virtuozzo.com>2016-10-07 19:57:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-07 21:46:26 -0400
commit7c5f64f84483bd13886348edda8b3e7b799a7fdb (patch)
tree426501049f6999c5f1a8c95ad17926198003c466 /include/linux/oom.h
parent48e509ece97e00b68e52d1d18e3e4b809c5b3991 (diff)
mm: oom: deduplicate victim selection code for memcg and global oom
When selecting an oom victim, we use the same heuristic for both memory cgroup and global oom. The only difference is the scope of tasks to select the victim from. So we could just export an iterator over all memcg tasks and keep all oom related logic in oom_kill.c, but instead we duplicate pieces of it in memcontrol.c reusing some initially private functions of oom_kill.c in order to not duplicate all of it. That looks ugly and error prone, because any modification of select_bad_process should also be propagated to mem_cgroup_out_of_memory. Let's rework this as follows: keep all oom heuristic related code private to oom_kill.c and make oom_kill.c use exported memcg functions when it's really necessary (like in case of iterating over memcg tasks). Link: http://lkml.kernel.org/r/1470056933-7505-1-git-send-email-vdavydov@virtuozzo.com Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/oom.h')
-rw-r--r--include/linux/oom.h43
1 files changed, 4 insertions, 39 deletions
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 5bc0457ee3a8..17946e5121b6 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -34,23 +34,11 @@ struct oom_control {
34 * for display purposes. 34 * for display purposes.
35 */ 35 */
36 const int order; 36 const int order;
37};
38 37
39/* 38 /* Used by oom implementation, do not set */
40 * Types of limitations to the nodes from which allocations may occur 39 unsigned long totalpages;
41 */ 40 struct task_struct *chosen;
42enum oom_constraint { 41 unsigned long chosen_points;
43 CONSTRAINT_NONE,
44 CONSTRAINT_CPUSET,
45 CONSTRAINT_MEMORY_POLICY,
46 CONSTRAINT_MEMCG,
47};
48
49enum oom_scan_t {
50 OOM_SCAN_OK, /* scan thread and find its badness */
51 OOM_SCAN_CONTINUE, /* do not consider thread for oom kill */
52 OOM_SCAN_ABORT, /* abort the iteration and return */
53 OOM_SCAN_SELECT, /* always select this thread first */
54}; 42};
55 43
56extern struct mutex oom_lock; 44extern struct mutex oom_lock;
@@ -70,30 +58,10 @@ static inline bool oom_task_origin(const struct task_struct *p)
70 return p->signal->oom_flag_origin; 58 return p->signal->oom_flag_origin;
71} 59}
72 60
73extern void mark_oom_victim(struct task_struct *tsk);
74
75#ifdef CONFIG_MMU
76extern void wake_oom_reaper(struct task_struct *tsk);
77#else
78static inline void wake_oom_reaper(struct task_struct *tsk)
79{
80}
81#endif
82
83extern unsigned long oom_badness(struct task_struct *p, 61extern unsigned long oom_badness(struct task_struct *p,
84 struct mem_cgroup *memcg, const nodemask_t *nodemask, 62 struct mem_cgroup *memcg, const nodemask_t *nodemask,
85 unsigned long totalpages); 63 unsigned long totalpages);
86 64
87extern void oom_kill_process(struct oom_control *oc, struct task_struct *p,
88 unsigned int points, unsigned long totalpages,
89 const char *message);
90
91extern void check_panic_on_oom(struct oom_control *oc,
92 enum oom_constraint constraint);
93
94extern enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
95 struct task_struct *task);
96
97extern bool out_of_memory(struct oom_control *oc); 65extern bool out_of_memory(struct oom_control *oc);
98 66
99extern void exit_oom_victim(struct task_struct *tsk); 67extern void exit_oom_victim(struct task_struct *tsk);
@@ -101,14 +69,11 @@ extern void exit_oom_victim(struct task_struct *tsk);
101extern int register_oom_notifier(struct notifier_block *nb); 69extern int register_oom_notifier(struct notifier_block *nb);
102extern int unregister_oom_notifier(struct notifier_block *nb); 70extern int unregister_oom_notifier(struct notifier_block *nb);
103 71
104extern bool oom_killer_disabled;
105extern bool oom_killer_disable(void); 72extern bool oom_killer_disable(void);
106extern void oom_killer_enable(void); 73extern void oom_killer_enable(void);
107 74
108extern struct task_struct *find_lock_task_mm(struct task_struct *p); 75extern struct task_struct *find_lock_task_mm(struct task_struct *p);
109 76
110bool task_will_free_mem(struct task_struct *task);
111
112/* sysctls */ 77/* sysctls */
113extern int sysctl_oom_dump_tasks; 78extern int sysctl_oom_dump_tasks;
114extern int sysctl_oom_kill_allocating_task; 79extern int sysctl_oom_kill_allocating_task;