]>
Commit | Line | Data |
---|---|---|
8ac773b4 AD |
1 | #ifndef __INCLUDE_LINUX_OOM_H |
2 | #define __INCLUDE_LINUX_OOM_H | |
3 | ||
5a3135c2 | 4 | |
a63d83f4 | 5 | #include <linux/sched.h> |
172acf60 | 6 | #include <linux/types.h> |
4365a567 | 7 | #include <linux/nodemask.h> |
607ca46e | 8 | #include <uapi/linux/oom.h> |
172acf60 DR |
9 | |
10 | struct zonelist; | |
11 | struct notifier_block; | |
74bcbf40 AM |
12 | struct mem_cgroup; |
13 | struct task_struct; | |
172acf60 | 14 | |
8989e4c7 DR |
15 | /* |
16 | * Details of the page allocation that triggered the oom killer that are used to | |
17 | * determine what should be killed. | |
18 | */ | |
6e0fc46d | 19 | struct oom_control { |
8989e4c7 | 20 | /* Used to determine cpuset */ |
6e0fc46d | 21 | struct zonelist *zonelist; |
8989e4c7 DR |
22 | |
23 | /* Used to determine mempolicy */ | |
24 | nodemask_t *nodemask; | |
25 | ||
2a966b77 VD |
26 | /* Memory cgroup in which oom is invoked, or NULL for global oom */ |
27 | struct mem_cgroup *memcg; | |
28 | ||
8989e4c7 DR |
29 | /* Used to determine cpuset and node locality requirement */ |
30 | const gfp_t gfp_mask; | |
31 | ||
32 | /* | |
33 | * order == -1 means the oom kill is required by sysrq, otherwise only | |
34 | * for display purposes. | |
35 | */ | |
36 | const int order; | |
6e0fc46d | 37 | |
7c5f64f8 VD |
38 | /* Used by oom implementation, do not set */ |
39 | unsigned long totalpages; | |
40 | struct task_struct *chosen; | |
41 | unsigned long chosen_points; | |
9cbb78bb DR |
42 | }; |
43 | ||
dc56401f JW |
44 | extern struct mutex oom_lock; |
45 | ||
e1e12d2f DR |
46 | static inline void set_current_oom_origin(void) |
47 | { | |
c96fc2d8 | 48 | current->signal->oom_flag_origin = true; |
e1e12d2f DR |
49 | } |
50 | ||
51 | static inline void clear_current_oom_origin(void) | |
52 | { | |
c96fc2d8 | 53 | current->signal->oom_flag_origin = false; |
e1e12d2f DR |
54 | } |
55 | ||
56 | static inline bool oom_task_origin(const struct task_struct *p) | |
57 | { | |
c96fc2d8 | 58 | return p->signal->oom_flag_origin; |
e1e12d2f | 59 | } |
72788c38 | 60 | |
862e3073 MH |
61 | static inline bool tsk_is_oom_victim(struct task_struct * tsk) |
62 | { | |
63 | return tsk->signal->oom_mm; | |
64 | } | |
65 | ||
a7f638f9 DR |
66 | extern unsigned long oom_badness(struct task_struct *p, |
67 | struct mem_cgroup *memcg, const nodemask_t *nodemask, | |
68 | unsigned long totalpages); | |
5695be14 | 69 | |
6e0fc46d | 70 | extern bool out_of_memory(struct oom_control *oc); |
16e95196 | 71 | |
38531201 | 72 | extern void exit_oom_victim(void); |
16e95196 | 73 | |
5a3135c2 DR |
74 | extern int register_oom_notifier(struct notifier_block *nb); |
75 | extern int unregister_oom_notifier(struct notifier_block *nb); | |
76 | ||
7d2e7a22 | 77 | extern bool oom_killer_disable(signed long timeout); |
c32b3cbe | 78 | extern void oom_killer_enable(void); |
8e4228e1 | 79 | |
158e0a2d KH |
80 | extern struct task_struct *find_lock_task_mm(struct task_struct *p); |
81 | ||
8e4228e1 DR |
82 | /* sysctls */ |
83 | extern int sysctl_oom_dump_tasks; | |
84 | extern int sysctl_oom_kill_allocating_task; | |
85 | extern int sysctl_panic_on_oom; | |
5a3135c2 | 86 | #endif /* _INCLUDE_LINUX_OOM_H */ |