cpuset.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. #include <linux/mm.h>
  15. #ifdef CONFIG_CPUSETS
  16. extern int number_of_cpusets; /* How many cpusets are defined in system? */
  17. extern int cpuset_init_early(void);
  18. extern int cpuset_init(void);
  19. extern void cpuset_init_smp(void);
  20. extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
  21. extern void cpuset_cpus_allowed_locked(struct task_struct *p,
  22. struct cpumask *mask);
  23. extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
  24. #define cpuset_current_mems_allowed (current->mems_allowed)
  25. void cpuset_init_current_mems_allowed(void);
  26. void cpuset_update_task_memory_state(void);
  27. int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
  28. extern int __cpuset_node_allowed_softwall(int node, gfp_t gfp_mask);
  29. extern int __cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask);
  30. static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
  31. {
  32. return number_of_cpusets <= 1 ||
  33. __cpuset_node_allowed_softwall(node, gfp_mask);
  34. }
  35. static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
  36. {
  37. return number_of_cpusets <= 1 ||
  38. __cpuset_node_allowed_hardwall(node, gfp_mask);
  39. }
  40. static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  41. {
  42. return cpuset_node_allowed_softwall(zone_to_nid(z), gfp_mask);
  43. }
  44. static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  45. {
  46. return cpuset_node_allowed_hardwall(zone_to_nid(z), gfp_mask);
  47. }
  48. extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
  49. const struct task_struct *tsk2);
  50. #define cpuset_memory_pressure_bump() \
  51. do { \
  52. if (cpuset_memory_pressure_enabled) \
  53. __cpuset_memory_pressure_bump(); \
  54. } while (0)
  55. extern int cpuset_memory_pressure_enabled;
  56. extern void __cpuset_memory_pressure_bump(void);
  57. extern const struct file_operations proc_cpuset_operations;
  58. struct seq_file;
  59. extern void cpuset_task_status_allowed(struct seq_file *m,
  60. struct task_struct *task);
  61. extern void cpuset_lock(void);
  62. extern void cpuset_unlock(void);
  63. extern int cpuset_mem_spread_node(void);
  64. static inline int cpuset_do_page_mem_spread(void)
  65. {
  66. return current->flags & PF_SPREAD_PAGE;
  67. }
  68. static inline int cpuset_do_slab_mem_spread(void)
  69. {
  70. return current->flags & PF_SPREAD_SLAB;
  71. }
  72. extern int current_cpuset_is_being_rebound(void);
  73. extern void rebuild_sched_domains(void);
  74. extern void cpuset_print_task_mems_allowed(struct task_struct *p);
  75. #else /* !CONFIG_CPUSETS */
  76. static inline int cpuset_init_early(void) { return 0; }
  77. static inline int cpuset_init(void) { return 0; }
  78. static inline void cpuset_init_smp(void) {}
  79. static inline void cpuset_cpus_allowed(struct task_struct *p,
  80. struct cpumask *mask)
  81. {
  82. cpumask_copy(mask, cpu_possible_mask);
  83. }
  84. static inline void cpuset_cpus_allowed_locked(struct task_struct *p,
  85. struct cpumask *mask)
  86. {
  87. cpumask_copy(mask, cpu_possible_mask);
  88. }
  89. static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
  90. {
  91. return node_possible_map;
  92. }
  93. #define cpuset_current_mems_allowed (node_states[N_HIGH_MEMORY])
  94. static inline void cpuset_init_current_mems_allowed(void) {}
  95. static inline void cpuset_update_task_memory_state(void) {}
  96. static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
  97. {
  98. return 1;
  99. }
  100. static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
  101. {
  102. return 1;
  103. }
  104. static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
  105. {
  106. return 1;
  107. }
  108. static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  109. {
  110. return 1;
  111. }
  112. static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  113. {
  114. return 1;
  115. }
  116. static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
  117. const struct task_struct *tsk2)
  118. {
  119. return 1;
  120. }
  121. static inline void cpuset_memory_pressure_bump(void) {}
  122. static inline void cpuset_task_status_allowed(struct seq_file *m,
  123. struct task_struct *task)
  124. {
  125. }
  126. static inline void cpuset_lock(void) {}
  127. static inline void cpuset_unlock(void) {}
  128. static inline int cpuset_mem_spread_node(void)
  129. {
  130. return 0;
  131. }
  132. static inline int cpuset_do_page_mem_spread(void)
  133. {
  134. return 0;
  135. }
  136. static inline int cpuset_do_slab_mem_spread(void)
  137. {
  138. return 0;
  139. }
  140. static inline int current_cpuset_is_being_rebound(void)
  141. {
  142. return 0;
  143. }
  144. static inline void rebuild_sched_domains(void)
  145. {
  146. partition_sched_domains(1, NULL, NULL);
  147. }
  148. static inline void cpuset_print_task_mems_allowed(struct task_struct *p)
  149. {
  150. }
  151. #endif /* !CONFIG_CPUSETS */
  152. #endif /* _LINUX_CPUSET_H */