oom.h 1.9 KB
Newer Older
1 2 3
#ifndef __INCLUDE_LINUX_OOM_H
#define __INCLUDE_LINUX_OOM_H

D
David Rientjes 已提交
4
/*
D
David Rientjes 已提交
5 6 7
 * /proc/<pid>/oom_adj is deprecated, see
 * Documentation/feature-removal-schedule.txt.
 *
D
David Rientjes 已提交
8 9
 * /proc/<pid>/oom_adj set to -17 protects from the oom-killer
 */
10 11 12 13 14
#define OOM_DISABLE (-17)
/* inclusive */
#define OOM_ADJUST_MIN (-16)
#define OOM_ADJUST_MAX 15

D
David Rientjes 已提交
15 16 17 18 19 20 21
/*
 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for
 * pid.
 */
#define OOM_SCORE_ADJ_MIN	(-1000)
#define OOM_SCORE_ADJ_MAX	1000

22 23
#ifdef __KERNEL__

D
David Rientjes 已提交
24
#include <linux/sched.h>
25
#include <linux/types.h>
26
#include <linux/nodemask.h>
27 28 29

struct zonelist;
struct notifier_block;
30 31
struct mem_cgroup;
struct task_struct;
32

D
David Rientjes 已提交
33 34 35 36 37 38 39
/*
 * Types of limitations to the nodes from which allocations may occur
 */
enum oom_constraint {
	CONSTRAINT_NONE,
	CONSTRAINT_CPUSET,
	CONSTRAINT_MEMORY_POLICY,
40
	CONSTRAINT_MEMCG,
D
David Rientjes 已提交
41 42
};

D
David Rientjes 已提交
43 44
extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
			const nodemask_t *nodemask, unsigned long totalpages);
45
extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
46
extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
D
David Rientjes 已提交
47

48 49
extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
		int order, nodemask_t *mask);
50 51 52
extern int register_oom_notifier(struct notifier_block *nb);
extern int unregister_oom_notifier(struct notifier_block *nb);

53 54 55 56 57 58 59 60 61 62 63
extern bool oom_killer_disabled;

static inline void oom_killer_disable(void)
{
	oom_killer_disabled = true;
}

static inline void oom_killer_enable(void)
{
	oom_killer_disabled = false;
}
64

65 66 67 68
/* The badness from the OOM killer */
extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
		      const nodemask_t *nodemask, unsigned long uptime);

69 70
extern struct task_struct *find_lock_task_mm(struct task_struct *p);

71 72 73 74
/* sysctls */
extern int sysctl_oom_dump_tasks;
extern int sysctl_oom_kill_allocating_task;
extern int sysctl_panic_on_oom;
75 76
#endif /* __KERNEL__*/
#endif /* _INCLUDE_LINUX_OOM_H */