Alexey Dobriyan | 8ac773b | 2006-10-19 23:28:32 -0700 | [diff] [blame] | 1 | #ifndef __INCLUDE_LINUX_OOM_H |
| 2 | #define __INCLUDE_LINUX_OOM_H |
| 3 | |
| 4 | /* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */ |
| 5 | #define OOM_DISABLE (-17) |
| 6 | /* inclusive */ |
| 7 | #define OOM_ADJUST_MIN (-16) |
| 8 | #define OOM_ADJUST_MAX 15 |
| 9 | |
David Rientjes | 5a3135c | 2007-10-16 23:25:53 -0700 | [diff] [blame] | 10 | #ifdef __KERNEL__ |
| 11 | |
David Rientjes | 172acf6 | 2007-10-16 23:25:59 -0700 | [diff] [blame] | 12 | #include <linux/types.h> |
KAMEZAWA Hiroyuki | 4365a56 | 2009-12-15 16:45:33 -0800 | [diff] [blame] | 13 | #include <linux/nodemask.h> |
David Rientjes | 172acf6 | 2007-10-16 23:25:59 -0700 | [diff] [blame] | 14 | |
| 15 | struct zonelist; |
| 16 | struct notifier_block; |
Andrew Morton | 74bcbf4 | 2010-08-09 17:19:43 -0700 | [diff] [blame^] | 17 | struct mem_cgroup; |
| 18 | struct task_struct; |
David Rientjes | 172acf6 | 2007-10-16 23:25:59 -0700 | [diff] [blame] | 19 | |
David Rientjes | 70e24bd | 2007-10-16 23:25:53 -0700 | [diff] [blame] | 20 | /* |
| 21 | * Types of limitations to the nodes from which allocations may occur |
| 22 | */ |
| 23 | enum oom_constraint { |
| 24 | CONSTRAINT_NONE, |
| 25 | CONSTRAINT_CPUSET, |
| 26 | CONSTRAINT_MEMORY_POLICY, |
David Rientjes | 309ed88 | 2010-08-09 17:18:54 -0700 | [diff] [blame] | 27 | CONSTRAINT_MEMCG, |
David Rientjes | 70e24bd | 2007-10-16 23:25:53 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Minchan Kim | ff321fe | 2010-08-09 17:18:57 -0700 | [diff] [blame] | 30 | extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags); |
Mel Gorman | dd1a239 | 2008-04-28 02:12:17 -0700 | [diff] [blame] | 31 | extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags); |
David Rientjes | 098d7f1 | 2007-10-16 23:25:55 -0700 | [diff] [blame] | 32 | |
KAMEZAWA Hiroyuki | 4365a56 | 2009-12-15 16:45:33 -0800 | [diff] [blame] | 33 | extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, |
| 34 | int order, nodemask_t *mask); |
David Rientjes | 5a3135c | 2007-10-16 23:25:53 -0700 | [diff] [blame] | 35 | extern int register_oom_notifier(struct notifier_block *nb); |
| 36 | extern int unregister_oom_notifier(struct notifier_block *nb); |
| 37 | |
Alexey Dobriyan | 1a8670a | 2009-09-21 17:03:09 -0700 | [diff] [blame] | 38 | extern bool oom_killer_disabled; |
| 39 | |
| 40 | static inline void oom_killer_disable(void) |
| 41 | { |
| 42 | oom_killer_disabled = true; |
| 43 | } |
| 44 | |
| 45 | static inline void oom_killer_enable(void) |
| 46 | { |
| 47 | oom_killer_disabled = false; |
| 48 | } |
David Rientjes | 8e4228e | 2010-08-09 17:18:56 -0700 | [diff] [blame] | 49 | |
Andrew Morton | 74bcbf4 | 2010-08-09 17:19:43 -0700 | [diff] [blame^] | 50 | /* The badness from the OOM killer */ |
| 51 | extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem, |
| 52 | const nodemask_t *nodemask, unsigned long uptime); |
| 53 | |
David Rientjes | 8e4228e | 2010-08-09 17:18:56 -0700 | [diff] [blame] | 54 | /* sysctls */ |
| 55 | extern int sysctl_oom_dump_tasks; |
| 56 | extern int sysctl_oom_kill_allocating_task; |
| 57 | extern int sysctl_panic_on_oom; |
David Rientjes | 5a3135c | 2007-10-16 23:25:53 -0700 | [diff] [blame] | 58 | #endif /* __KERNEL__*/ |
| 59 | #endif /* _INCLUDE_LINUX_OOM_H */ |