oom.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __INCLUDE_LINUX_OOM_H
  2. #define __INCLUDE_LINUX_OOM_H
  3. /* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
  4. #define OOM_DISABLE (-17)
  5. /* inclusive */
  6. #define OOM_ADJUST_MIN (-16)
  7. #define OOM_ADJUST_MAX 15
  8. #ifdef __KERNEL__
  9. #include <linux/types.h>
  10. #include <linux/nodemask.h>
  11. struct zonelist;
  12. struct notifier_block;
  13. /*
  14. * Types of limitations to the nodes from which allocations may occur
  15. */
  16. enum oom_constraint {
  17. CONSTRAINT_NONE,
  18. CONSTRAINT_CPUSET,
  19. CONSTRAINT_MEMORY_POLICY,
  20. CONSTRAINT_MEMCG,
  21. };
  22. extern int try_set_zone_oom(struct zonelist *zonelist, gfp_t gfp_flags);
  23. extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
  24. extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
  25. int order, nodemask_t *mask);
  26. extern int register_oom_notifier(struct notifier_block *nb);
  27. extern int unregister_oom_notifier(struct notifier_block *nb);
  28. extern bool oom_killer_disabled;
  29. static inline void oom_killer_disable(void)
  30. {
  31. oom_killer_disabled = true;
  32. }
  33. static inline void oom_killer_enable(void)
  34. {
  35. oom_killer_disabled = false;
  36. }
  37. /* sysctls */
  38. extern int sysctl_oom_dump_tasks;
  39. extern int sysctl_oom_kill_allocating_task;
  40. extern int sysctl_panic_on_oom;
  41. #endif /* __KERNEL__*/
  42. #endif /* _INCLUDE_LINUX_OOM_H */