oom.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #endif /* __KERNEL__*/
  38. #endif /* _INCLUDE_LINUX_OOM_H */