blob: d36a8221f58be3ac51ae37730469c380a433149e [file] [log] [blame]
Alexey Dobriyan8ac773b2006-10-19 23:28:32 -07001#ifndef __INCLUDE_LINUX_OOM_H
2#define __INCLUDE_LINUX_OOM_H
3
David Rientjesa63d83f2010-08-09 17:19:46 -07004/*
David Rientjesa63d83f2010-08-09 17:19:46 -07005 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for
6 * pid.
7 */
8#define OOM_SCORE_ADJ_MIN (-1000)
9#define OOM_SCORE_ADJ_MAX 1000
10
David Rientjes5a3135c22007-10-16 23:25:53 -070011#ifdef __KERNEL__
12
David Rientjesa63d83f2010-08-09 17:19:46 -070013#include <linux/sched.h>
David Rientjes172acf62007-10-16 23:25:59 -070014#include <linux/types.h>
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080015#include <linux/nodemask.h>
David Rientjes172acf62007-10-16 23:25:59 -070016
17struct zonelist;
18struct notifier_block;
Andrew Morton74bcbf42010-08-09 17:19:43 -070019struct mem_cgroup;
20struct task_struct;
David Rientjes172acf62007-10-16 23:25:59 -070021
David Rientjes70e24bd2007-10-16 23:25:53 -070022/*
23 * Types of limitations to the nodes from which allocations may occur
24 */
25enum oom_constraint {
26 CONSTRAINT_NONE,
27 CONSTRAINT_CPUSET,
28 CONSTRAINT_MEMORY_POLICY,
David Rientjes309ed882010-08-09 17:18:54 -070029 CONSTRAINT_MEMCG,
David Rientjes70e24bd2007-10-16 23:25:53 -070030};
31
David Rientjes9cbb78b2012-07-31 16:43:44 -070032enum oom_scan_t {
33 OOM_SCAN_OK, /* scan thread and find its badness */
34 OOM_SCAN_CONTINUE, /* do not consider thread for oom kill */
35 OOM_SCAN_ABORT, /* abort the iteration and return */
36 OOM_SCAN_SELECT, /* always select this thread first */
37};
38
David Rientjes43362a42011-10-31 17:07:18 -070039extern void compare_swap_oom_score_adj(int old_val, int new_val);
David Rientjes72788c32011-05-24 17:11:40 -070040extern int test_set_oom_score_adj(int new_val);
41
David Rientjesa7f638f2012-05-29 15:06:47 -070042extern unsigned long oom_badness(struct task_struct *p,
43 struct mem_cgroup *memcg, const nodemask_t *nodemask,
44 unsigned long totalpages);
David Rientjes9cbb78b2012-07-31 16:43:44 -070045extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
46 unsigned int points, unsigned long totalpages,
47 struct mem_cgroup *memcg, nodemask_t *nodemask,
48 const char *message);
49
Minchan Kimff321fe2010-08-09 17:18:57 -070050extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070051extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070052
David Rientjes876aafb2012-07-31 16:43:48 -070053extern void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask,
54 int order, const nodemask_t *nodemask);
55
David Rientjes9cbb78b2012-07-31 16:43:44 -070056extern enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
57 unsigned long totalpages, const nodemask_t *nodemask,
58 bool force_kill);
David Rientjes62ce1c72012-07-31 16:43:39 -070059extern void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
60 int order);
David Rientjes9cbb78b2012-07-31 16:43:44 -070061
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080062extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
David Rientjes08ab9b12012-03-21 16:34:04 -070063 int order, nodemask_t *mask, bool force_kill);
David Rientjes5a3135c22007-10-16 23:25:53 -070064extern int register_oom_notifier(struct notifier_block *nb);
65extern int unregister_oom_notifier(struct notifier_block *nb);
66
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070067extern bool oom_killer_disabled;
68
69static inline void oom_killer_disable(void)
70{
71 oom_killer_disabled = true;
72}
73
74static inline void oom_killer_enable(void)
75{
76 oom_killer_disabled = false;
77}
David Rientjes8e4228e2010-08-09 17:18:56 -070078
KAMEZAWA Hiroyuki158e0a22010-08-10 18:03:00 -070079extern struct task_struct *find_lock_task_mm(struct task_struct *p);
80
David Rientjes8e4228e2010-08-09 17:18:56 -070081/* sysctls */
82extern int sysctl_oom_dump_tasks;
83extern int sysctl_oom_kill_allocating_task;
84extern int sysctl_panic_on_oom;
David Rientjes5a3135c22007-10-16 23:25:53 -070085#endif /* __KERNEL__*/
86#endif /* _INCLUDE_LINUX_OOM_H */