linux/include/linux/oom.h
<<
>>
Prefs
   1#ifndef __INCLUDE_LINUX_OOM_H
   2#define __INCLUDE_LINUX_OOM_H
   3
   4
   5#include <linux/sched.h>
   6#include <linux/types.h>
   7#include <linux/nodemask.h>
   8#include <uapi/linux/oom.h>
   9
  10struct zonelist;
  11struct notifier_block;
  12struct mem_cgroup;
  13struct task_struct;
  14
  15/*
  16 * Details of the page allocation that triggered the oom killer that are used to
  17 * determine what should be killed.
  18 */
  19struct oom_control {
  20        /* Used to determine cpuset */
  21        struct zonelist *zonelist;
  22
  23        /* Used to determine mempolicy */
  24        nodemask_t *nodemask;
  25
  26        /* Memory cgroup in which oom is invoked, or NULL for global oom */
  27        struct mem_cgroup *memcg;
  28
  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;
  37
  38        /* Used by oom implementation, do not set */
  39        unsigned long totalpages;
  40        struct task_struct *chosen;
  41        unsigned long chosen_points;
  42};
  43
  44extern struct mutex oom_lock;
  45
  46static inline void set_current_oom_origin(void)
  47{
  48        current->signal->oom_flag_origin = true;
  49}
  50
  51static inline void clear_current_oom_origin(void)
  52{
  53        current->signal->oom_flag_origin = false;
  54}
  55
  56static inline bool oom_task_origin(const struct task_struct *p)
  57{
  58        return p->signal->oom_flag_origin;
  59}
  60
  61static inline bool tsk_is_oom_victim(struct task_struct * tsk)
  62{
  63        return tsk->signal->oom_mm;
  64}
  65
  66extern unsigned long oom_badness(struct task_struct *p,
  67                struct mem_cgroup *memcg, const nodemask_t *nodemask,
  68                unsigned long totalpages);
  69
  70extern bool out_of_memory(struct oom_control *oc);
  71
  72extern void exit_oom_victim(void);
  73
  74extern int register_oom_notifier(struct notifier_block *nb);
  75extern int unregister_oom_notifier(struct notifier_block *nb);
  76
  77extern bool oom_killer_disable(signed long timeout);
  78extern void oom_killer_enable(void);
  79
  80extern struct task_struct *find_lock_task_mm(struct task_struct *p);
  81
  82/* sysctls */
  83extern int sysctl_oom_dump_tasks;
  84extern int sysctl_oom_kill_allocating_task;
  85extern int sysctl_panic_on_oom;
  86#endif /* _INCLUDE_LINUX_OOM_H */
  87