1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 #ifndef __INCLUDE_LINUX_OOM_H 1 #ifndef __INCLUDE_LINUX_OOM_H 3 #define __INCLUDE_LINUX_OOM_H 2 #define __INCLUDE_LINUX_OOM_H 4 3 5 4 6 #include <linux/sched/signal.h> 5 #include <linux/sched/signal.h> 7 #include <linux/types.h> 6 #include <linux/types.h> 8 #include <linux/nodemask.h> 7 #include <linux/nodemask.h> 9 #include <uapi/linux/oom.h> 8 #include <uapi/linux/oom.h> 10 #include <linux/sched/coredump.h> /* MMF_* */ << 11 #include <linux/mm.h> /* VM_FAULT* */ << 12 9 13 struct zonelist; 10 struct zonelist; 14 struct notifier_block; 11 struct notifier_block; 15 struct mem_cgroup; 12 struct mem_cgroup; 16 struct task_struct; 13 struct task_struct; 17 14 18 enum oom_constraint { << 19 CONSTRAINT_NONE, << 20 CONSTRAINT_CPUSET, << 21 CONSTRAINT_MEMORY_POLICY, << 22 CONSTRAINT_MEMCG, << 23 }; << 24 << 25 /* 15 /* 26 * Details of the page allocation that trigger 16 * Details of the page allocation that triggered the oom killer that are used to 27 * determine what should be killed. 17 * determine what should be killed. 28 */ 18 */ 29 struct oom_control { 19 struct oom_control { 30 /* Used to determine cpuset */ 20 /* Used to determine cpuset */ 31 struct zonelist *zonelist; 21 struct zonelist *zonelist; 32 22 33 /* Used to determine mempolicy */ 23 /* Used to determine mempolicy */ 34 nodemask_t *nodemask; 24 nodemask_t *nodemask; 35 25 36 /* Memory cgroup in which oom is invok 26 /* Memory cgroup in which oom is invoked, or NULL for global oom */ 37 struct mem_cgroup *memcg; 27 struct mem_cgroup *memcg; 38 28 39 /* Used to determine cpuset and node l 29 /* Used to determine cpuset and node locality requirement */ 40 const gfp_t gfp_mask; 30 const gfp_t gfp_mask; 41 31 42 /* 32 /* 43 * order == -1 means the oom kill is r 33 * order == -1 means the oom kill is required by sysrq, otherwise only 44 * for display purposes. 34 * for display purposes. 45 */ 35 */ 46 const int order; 36 const int order; 47 37 48 /* Used by oom implementation, do not 38 /* Used by oom implementation, do not set */ 49 unsigned long totalpages; 39 unsigned long totalpages; 50 struct task_struct *chosen; 40 struct task_struct *chosen; 51 long chosen_points; !! 41 unsigned long chosen_points; 52 << 53 /* Used to print the constraint info. << 54 enum oom_constraint constraint; << 55 }; 42 }; 56 43 57 extern struct mutex oom_lock; 44 extern struct mutex oom_lock; 58 extern struct mutex oom_adj_mutex; << 59 45 60 static inline void set_current_oom_origin(void 46 static inline void set_current_oom_origin(void) 61 { 47 { 62 current->signal->oom_flag_origin = tru 48 current->signal->oom_flag_origin = true; 63 } 49 } 64 50 65 static inline void clear_current_oom_origin(vo 51 static inline void clear_current_oom_origin(void) 66 { 52 { 67 current->signal->oom_flag_origin = fal 53 current->signal->oom_flag_origin = false; 68 } 54 } 69 55 70 static inline bool oom_task_origin(const struc 56 static inline bool oom_task_origin(const struct task_struct *p) 71 { 57 { 72 return p->signal->oom_flag_origin; 58 return p->signal->oom_flag_origin; 73 } 59 } 74 60 75 static inline bool tsk_is_oom_victim(struct ta 61 static inline bool tsk_is_oom_victim(struct task_struct * tsk) 76 { 62 { 77 return tsk->signal->oom_mm; 63 return tsk->signal->oom_mm; 78 } 64 } 79 65 80 /* !! 66 extern unsigned long oom_badness(struct task_struct *p, 81 * Checks whether a page fault on the given mm !! 67 struct mem_cgroup *memcg, const nodemask_t *nodemask, 82 * This is no longer true if the oom reaper st << 83 * address space which is reflected by MMF_UNS << 84 * the mm. At that moment any !shared mapping << 85 * and could cause a memory corruption (zero p << 86 * original content). << 87 * << 88 * User should call this before establishing a << 89 * a !shared mapping and under the proper page << 90 * << 91 * Return 0 when the PF is safe VM_FAULT_SIGBU << 92 */ << 93 static inline vm_fault_t check_stable_address_ << 94 { << 95 if (unlikely(test_bit(MMF_UNSTABLE, &m << 96 return VM_FAULT_SIGBUS; << 97 return 0; << 98 } << 99 << 100 long oom_badness(struct task_struct *p, << 101 unsigned long totalpages); 68 unsigned long totalpages); 102 69 103 extern bool out_of_memory(struct oom_control * 70 extern bool out_of_memory(struct oom_control *oc); 104 71 105 extern void exit_oom_victim(void); 72 extern void exit_oom_victim(void); 106 73 107 extern int register_oom_notifier(struct notifi 74 extern int register_oom_notifier(struct notifier_block *nb); 108 extern int unregister_oom_notifier(struct noti 75 extern int unregister_oom_notifier(struct notifier_block *nb); 109 76 110 extern bool oom_killer_disable(signed long tim 77 extern bool oom_killer_disable(signed long timeout); 111 extern void oom_killer_enable(void); 78 extern void oom_killer_enable(void); 112 79 113 extern struct task_struct *find_lock_task_mm(s 80 extern struct task_struct *find_lock_task_mm(struct task_struct *p); 114 81 >> 82 /* sysctls */ >> 83 extern int sysctl_oom_dump_tasks; >> 84 extern int sysctl_oom_kill_allocating_task; >> 85 extern int sysctl_panic_on_oom; 115 #endif /* _INCLUDE_LINUX_OOM_H */ 86 #endif /* _INCLUDE_LINUX_OOM_H */ 116 87
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.