blob: 73b8d7b6dd19055183206d25f336876073a7d0e7 [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/*
5 * /proc/<pid>/oom_adj set to -17 protects from the oom-killer
6 */
Alexey Dobriyan8ac773b2006-10-19 23:28:32 -07007#define OOM_DISABLE (-17)
8/* inclusive */
9#define OOM_ADJUST_MIN (-16)
10#define OOM_ADJUST_MAX 15
11
David Rientjesa63d83f2010-08-09 17:19:46 -070012/*
13 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for
14 * pid.
15 */
16#define OOM_SCORE_ADJ_MIN (-1000)
17#define OOM_SCORE_ADJ_MAX 1000
18
David Rientjes5a3135c2007-10-16 23:25:53 -070019#ifdef __KERNEL__
20
David Rientjesa63d83f2010-08-09 17:19:46 -070021#include <linux/sched.h>
David Rientjes172acf62007-10-16 23:25:59 -070022#include <linux/types.h>
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080023#include <linux/nodemask.h>
David Rientjes172acf62007-10-16 23:25:59 -070024
25struct zonelist;
26struct notifier_block;
Andrew Morton74bcbf42010-08-09 17:19:43 -070027struct mem_cgroup;
28struct task_struct;
David Rientjes172acf62007-10-16 23:25:59 -070029
David Rientjes70e24bd2007-10-16 23:25:53 -070030/*
31 * Types of limitations to the nodes from which allocations may occur
32 */
33enum oom_constraint {
34 CONSTRAINT_NONE,
35 CONSTRAINT_CPUSET,
36 CONSTRAINT_MEMORY_POLICY,
David Rientjes309ed882010-08-09 17:18:54 -070037 CONSTRAINT_MEMCG,
David Rientjes70e24bd2007-10-16 23:25:53 -070038};
39
David Rientjesa63d83f2010-08-09 17:19:46 -070040extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
41 const nodemask_t *nodemask, unsigned long totalpages);
Minchan Kimff321fe2010-08-09 17:18:57 -070042extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070043extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070044
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080045extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
46 int order, nodemask_t *mask);
David Rientjes5a3135c2007-10-16 23:25:53 -070047extern int register_oom_notifier(struct notifier_block *nb);
48extern int unregister_oom_notifier(struct notifier_block *nb);
49
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070050extern bool oom_killer_disabled;
51
52static inline void oom_killer_disable(void)
53{
54 oom_killer_disabled = true;
55}
56
57static inline void oom_killer_enable(void)
58{
59 oom_killer_disabled = false;
60}
David Rientjes8e4228e2010-08-09 17:18:56 -070061
Andrew Morton74bcbf42010-08-09 17:19:43 -070062/* The badness from the OOM killer */
63extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
64 const nodemask_t *nodemask, unsigned long uptime);
65
David Rientjes8e4228e2010-08-09 17:18:56 -070066/* sysctls */
67extern int sysctl_oom_dump_tasks;
68extern int sysctl_oom_kill_allocating_task;
69extern int sysctl_panic_on_oom;
David Rientjes5a3135c2007-10-16 23:25:53 -070070#endif /* __KERNEL__*/
71#endif /* _INCLUDE_LINUX_OOM_H */