oom.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __INCLUDE_LINUX_OOM_H
  2. #define __INCLUDE_LINUX_OOM_H
  3. #include <linux/sched.h>
  4. #include <linux/types.h>
  5. #include <linux/nodemask.h>
  6. #include <uapi/linux/oom.h>
  7. struct zonelist;
  8. struct notifier_block;
  9. struct mem_cgroup;
  10. struct task_struct;
  11. /*
  12. * Details of the page allocation that triggered the oom killer that are used to
  13. * determine what should be killed.
  14. */
  15. struct oom_control {
  16. /* Used to determine cpuset */
  17. struct zonelist *zonelist;
  18. /* Used to determine mempolicy */
  19. nodemask_t *nodemask;
  20. /* Memory cgroup in which oom is invoked, or NULL for global oom */
  21. struct mem_cgroup *memcg;
  22. /* Used to determine cpuset and node locality requirement */
  23. const gfp_t gfp_mask;
  24. /*
  25. * order == -1 means the oom kill is required by sysrq, otherwise only
  26. * for display purposes.
  27. */
  28. const int order;
  29. /* Used by oom implementation, do not set */
  30. unsigned long totalpages;
  31. struct task_struct *chosen;
  32. unsigned long chosen_points;
  33. };
  34. extern struct mutex oom_lock;
  35. static inline void set_current_oom_origin(void)
  36. {
  37. current->signal->oom_flag_origin = true;
  38. }
  39. static inline void clear_current_oom_origin(void)
  40. {
  41. current->signal->oom_flag_origin = false;
  42. }
  43. static inline bool oom_task_origin(const struct task_struct *p)
  44. {
  45. return p->signal->oom_flag_origin;
  46. }
  47. static inline bool tsk_is_oom_victim(struct task_struct * tsk)
  48. {
  49. return tsk->signal->oom_mm;
  50. }
  51. extern unsigned long oom_badness(struct task_struct *p,
  52. struct mem_cgroup *memcg, const nodemask_t *nodemask,
  53. unsigned long totalpages);
  54. extern bool out_of_memory(struct oom_control *oc);
  55. extern void exit_oom_victim(void);
  56. extern int register_oom_notifier(struct notifier_block *nb);
  57. extern int unregister_oom_notifier(struct notifier_block *nb);
  58. extern bool oom_killer_disable(signed long timeout);
  59. extern void oom_killer_enable(void);
  60. extern struct task_struct *find_lock_task_mm(struct task_struct *p);
  61. /* sysctls */
  62. extern int sysctl_oom_dump_tasks;
  63. extern int sysctl_oom_kill_allocating_task;
  64. extern int sysctl_panic_on_oom;
  65. #endif /* _INCLUDE_LINUX_OOM_H */