blob: 40e5e3a6bc2018a2fee2bf43777ad749bce63101 [file] [log] [blame]
Alexey Dobriyan8ac773b2006-10-19 23:28:32 -07001#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 Rientjes5a3135c2007-10-16 23:25:53 -070010#ifdef __KERNEL__
11
David Rientjes172acf62007-10-16 23:25:59 -070012#include <linux/types.h>
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080013#include <linux/nodemask.h>
David Rientjes172acf62007-10-16 23:25:59 -070014
15struct zonelist;
16struct notifier_block;
Andrew Morton74bcbf42010-08-09 17:19:43 -070017struct mem_cgroup;
18struct task_struct;
David Rientjes172acf62007-10-16 23:25:59 -070019
David Rientjes70e24bd2007-10-16 23:25:53 -070020/*
21 * Types of limitations to the nodes from which allocations may occur
22 */
23enum oom_constraint {
24 CONSTRAINT_NONE,
25 CONSTRAINT_CPUSET,
26 CONSTRAINT_MEMORY_POLICY,
David Rientjes309ed882010-08-09 17:18:54 -070027 CONSTRAINT_MEMCG,
David Rientjes70e24bd2007-10-16 23:25:53 -070028};
29
Minchan Kimff321fe2010-08-09 17:18:57 -070030extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
Mel Gormandd1a2392008-04-28 02:12:17 -070031extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
David Rientjes098d7f12007-10-16 23:25:55 -070032
KAMEZAWA Hiroyuki4365a562009-12-15 16:45:33 -080033extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
34 int order, nodemask_t *mask);
David Rientjes5a3135c2007-10-16 23:25:53 -070035extern int register_oom_notifier(struct notifier_block *nb);
36extern int unregister_oom_notifier(struct notifier_block *nb);
37
Alexey Dobriyan1a8670a2009-09-21 17:03:09 -070038extern bool oom_killer_disabled;
39
40static inline void oom_killer_disable(void)
41{
42 oom_killer_disabled = true;
43}
44
45static inline void oom_killer_enable(void)
46{
47 oom_killer_disabled = false;
48}
David Rientjes8e4228e2010-08-09 17:18:56 -070049
Andrew Morton74bcbf42010-08-09 17:19:43 -070050/* The badness from the OOM killer */
51extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
52 const nodemask_t *nodemask, unsigned long uptime);
53
David Rientjes8e4228e2010-08-09 17:18:56 -070054/* sysctls */
55extern int sysctl_oom_dump_tasks;
56extern int sysctl_oom_kill_allocating_task;
57extern int sysctl_panic_on_oom;
David Rientjes5a3135c2007-10-16 23:25:53 -070058#endif /* __KERNEL__*/
59#endif /* _INCLUDE_LINUX_OOM_H */