blob: 3d7647536b0304ba40013aa2399d551b6779b4cf [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 Rientjes51b1bd22010-08-09 17:19:47 -07005 * /proc/<pid>/oom_adj is deprecated, see
6 * Documentation/feature-removal-schedule.txt.
7 *
David Rientjesa63d83f2010-08-09 17:19:46 -07008 * /proc/<pid>/oom_adj set to -17 protects from the oom-killer
9 */
Alexey Dobriyan8ac773b2006-10-19 23:28:32 -070010#define OOM_DISABLE (-17)
11/* inclusive */
12#define OOM_ADJUST_MIN (-16)
13#define OOM_ADJUST_MAX 15
14
David Rientjesa63d83f2010-08-09 17:19:46 -070015/*
16 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for
17 * pid.
18 */
19#define OOM_SCORE_ADJ_MIN (-1000)
20#define OOM_SCORE_ADJ_MAX 1000
21
David Rientjes5a3135c22007-10-16 23:25:53 -070022#ifdef __KERNEL__
23
David Rientjesa63d83f2010-08-09 17:19:46 -070024#include <linux/sched.h>
David Rientjes172acf62007-10-16 23:25:59 -070025#include <linux/types.h>
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080026#include <linux/nodemask.h>
David Rientjes172acf62007-10-16 23:25:59 -070027
28struct zonelist;
29struct notifier_block;
Andrew Morton74bcbf42010-08-09 17:19:43 -070030struct mem_cgroup;
31struct task_struct;
David Rientjes172acf62007-10-16 23:25:59 -070032
David Rientjes70e24bd2007-10-16 23:25:53 -070033/*
34 * Types of limitations to the nodes from which allocations may occur
35 */
36enum oom_constraint {
37 CONSTRAINT_NONE,
38 CONSTRAINT_CPUSET,
39 CONSTRAINT_MEMORY_POLICY,
David Rientjes309ed882010-08-09 17:18:54 -070040 CONSTRAINT_MEMCG,
David Rientjes70e24bd2007-10-16 23:25:53 -070041};
42
David Rientjes43362a42011-10-31 17:07:18 -070043extern void compare_swap_oom_score_adj(int old_val, int new_val);
David Rientjes72788c32011-05-24 17:11:40 -070044extern int test_set_oom_score_adj(int new_val);
45
Johannes Weiner72835c82012-01-12 17:18:32 -080046extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
David Rientjesa63d83f2010-08-09 17:19:46 -070047 const nodemask_t *nodemask, unsigned long totalpages);
Minchan Kimff321fe2010-08-09 17:18:57 -070048extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070049extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070050
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080051extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
David Rientjes08ab9b12012-03-21 16:34:04 -070052 int order, nodemask_t *mask, bool force_kill);
David Rientjes5a3135c22007-10-16 23:25:53 -070053extern int register_oom_notifier(struct notifier_block *nb);
54extern int unregister_oom_notifier(struct notifier_block *nb);
55
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070056extern bool oom_killer_disabled;
57
58static inline void oom_killer_disable(void)
59{
60 oom_killer_disabled = true;
61}
62
63static inline void oom_killer_enable(void)
64{
65 oom_killer_disabled = false;
66}
David Rientjes8e4228e2010-08-09 17:18:56 -070067
KAMEZAWA Hiroyuki158e0a22010-08-10 18:03:00 -070068extern struct task_struct *find_lock_task_mm(struct task_struct *p);
69
David Rientjes8e4228e2010-08-09 17:18:56 -070070/* sysctls */
71extern int sysctl_oom_dump_tasks;
72extern int sysctl_oom_kill_allocating_task;
73extern int sysctl_panic_on_oom;
David Rientjes5a3135c22007-10-16 23:25:53 -070074#endif /* __KERNEL__*/
75#endif /* _INCLUDE_LINUX_OOM_H */