cpuset.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef _LINUX_CPUSET_H
  2. #define _LINUX_CPUSET_H
  3. /*
  4. * cpuset interface
  5. *
  6. * Copyright (C) 2003 BULL SA
  7. * Copyright (C) 2004-2006 Silicon Graphics, Inc.
  8. *
  9. */
  10. #include <linux/sched.h>
  11. #include <linux/cpumask.h>
  12. #include <linux/nodemask.h>
  13. #include <linux/cgroup.h>
  14. #ifdef CONFIG_CPUSETS
  15. extern int number_of_cpusets; /* How many cpusets are defined in system? */
  16. extern int cpuset_init_early(void);
  17. extern int cpuset_init(void);
  18. extern void cpuset_init_smp(void);
  19. extern cpumask_t cpuset_cpus_allowed(struct task_struct *p);
  20. extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
  21. #define cpuset_current_mems_allowed (current->mems_allowed)
  22. void cpuset_init_current_mems_allowed(void);
  23. void cpuset_update_task_memory_state(void);
  24. #define cpuset_nodes_subset_current_mems_allowed(nodes) \
  25. nodes_subset((nodes), current->mems_allowed)
  26. int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
  27. extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask);
  28. extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask);
  29. static int inline cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  30. {
  31. return number_of_cpusets <= 1 ||
  32. __cpuset_zone_allowed_softwall(z, gfp_mask);
  33. }
  34. static int inline cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  35. {
  36. return number_of_cpusets <= 1 ||
  37. __cpuset_zone_allowed_hardwall(z, gfp_mask);
  38. }
  39. extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
  40. const struct task_struct *tsk2);
  41. #define cpuset_memory_pressure_bump() \
  42. do { \
  43. if (cpuset_memory_pressure_enabled) \
  44. __cpuset_memory_pressure_bump(); \
  45. } while (0)
  46. extern int cpuset_memory_pressure_enabled;
  47. extern void __cpuset_memory_pressure_bump(void);
  48. extern const struct file_operations proc_cpuset_operations;
  49. extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
  50. extern void cpuset_lock(void);
  51. extern void cpuset_unlock(void);
  52. extern int cpuset_mem_spread_node(void);
  53. static inline int cpuset_do_page_mem_spread(void)
  54. {
  55. return current->flags & PF_SPREAD_PAGE;
  56. }
  57. static inline int cpuset_do_slab_mem_spread(void)
  58. {
  59. return current->flags & PF_SPREAD_SLAB;
  60. }
  61. extern void cpuset_track_online_nodes(void);
  62. extern int current_cpuset_is_being_rebound(void);
  63. #else /* !CONFIG_CPUSETS */
  64. static inline int cpuset_init_early(void) { return 0; }
  65. static inline int cpuset_init(void) { return 0; }
  66. static inline void cpuset_init_smp(void) {}
  67. static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p)
  68. {
  69. return cpu_possible_map;
  70. }
  71. static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
  72. {
  73. return node_possible_map;
  74. }
  75. #define cpuset_current_mems_allowed (node_states[N_HIGH_MEMORY])
  76. static inline void cpuset_init_current_mems_allowed(void) {}
  77. static inline void cpuset_update_task_memory_state(void) {}
  78. #define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
  79. static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
  80. {
  81. return 1;
  82. }
  83. static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  84. {
  85. return 1;
  86. }
  87. static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  88. {
  89. return 1;
  90. }
  91. static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
  92. const struct task_struct *tsk2)
  93. {
  94. return 1;
  95. }
  96. static inline void cpuset_memory_pressure_bump(void) {}
  97. static inline char *cpuset_task_status_allowed(struct task_struct *task,
  98. char *buffer)
  99. {
  100. return buffer;
  101. }
  102. static inline void cpuset_lock(void) {}
  103. static inline void cpuset_unlock(void) {}
  104. static inline int cpuset_mem_spread_node(void)
  105. {
  106. return 0;
  107. }
  108. static inline int cpuset_do_page_mem_spread(void)
  109. {
  110. return 0;
  111. }
  112. static inline int cpuset_do_slab_mem_spread(void)
  113. {
  114. return 0;
  115. }
  116. static inline void cpuset_track_online_nodes(void) {}
  117. static inline int current_cpuset_is_being_rebound(void)
  118. {
  119. return 0;
  120. }
  121. #endif /* !CONFIG_CPUSETS */
  122. #endif /* _LINUX_CPUSET_H */