blob: 4952fb874ad3dadd631b3e10f0ae35eb0df59135 [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 Rientjes72788c32011-05-24 17:11:40 -070043extern int test_set_oom_score_adj(int new_val);
44
David Rientjesa63d83f2010-08-09 17:19:46 -070045extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
46 const nodemask_t *nodemask, unsigned long totalpages);
Minchan Kimff321fe2010-08-09 17:18:57 -070047extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070048extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070049
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080050extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
51 int order, nodemask_t *mask);
David Rientjes5a3135c22007-10-16 23:25:53 -070052extern int register_oom_notifier(struct notifier_block *nb);
53extern int unregister_oom_notifier(struct notifier_block *nb);
54
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070055extern bool oom_killer_disabled;
56
57static inline void oom_killer_disable(void)
58{
59 oom_killer_disabled = true;
60}
61
62static inline void oom_killer_enable(void)
63{
64 oom_killer_disabled = false;
65}
David Rientjes8e4228e2010-08-09 17:18:56 -070066
Andrew Morton74bcbf42010-08-09 17:19:43 -070067/* The badness from the OOM killer */
68extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
69 const nodemask_t *nodemask, unsigned long uptime);
70
KAMEZAWA Hiroyuki158e0a22010-08-10 18:03:00 -070071extern struct task_struct *find_lock_task_mm(struct task_struct *p);
72
David Rientjes8e4228e2010-08-09 17:18:56 -070073/* sysctls */
74extern int sysctl_oom_dump_tasks;
75extern int sysctl_oom_kill_allocating_task;
76extern int sysctl_panic_on_oom;
David Rientjes5a3135c22007-10-16 23:25:53 -070077#endif /* __KERNEL__*/
78#endif /* _INCLUDE_LINUX_OOM_H */