blob: 5e3aa8311c5ed40f2598ccd814162bef5173030e [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 Rientjesa63d83f2010-08-09 17:19:46 -070043extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
44 const nodemask_t *nodemask, unsigned long totalpages);
Minchan Kimff321fe2010-08-09 17:18:57 -070045extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070046extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070047
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080048extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
49 int order, nodemask_t *mask);
David Rientjes5a3135c22007-10-16 23:25:53 -070050extern int register_oom_notifier(struct notifier_block *nb);
51extern int unregister_oom_notifier(struct notifier_block *nb);
52
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070053extern bool oom_killer_disabled;
54
55static inline void oom_killer_disable(void)
56{
57 oom_killer_disabled = true;
58}
59
60static inline void oom_killer_enable(void)
61{
62 oom_killer_disabled = false;
63}
David Rientjes8e4228e2010-08-09 17:18:56 -070064
Andrew Morton74bcbf42010-08-09 17:19:43 -070065/* The badness from the OOM killer */
66extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
67 const nodemask_t *nodemask, unsigned long uptime);
68
KAMEZAWA Hiroyuki158e0a22010-08-10 18:03:00 -070069extern struct task_struct *find_lock_task_mm(struct task_struct *p);
70
David Rientjes8e4228e2010-08-09 17:18:56 -070071/* sysctls */
72extern int sysctl_oom_dump_tasks;
73extern int sysctl_oom_kill_allocating_task;
74extern int sysctl_panic_on_oom;
David Rientjes5a3135c22007-10-16 23:25:53 -070075#endif /* __KERNEL__*/
76#endif /* _INCLUDE_LINUX_OOM_H */