cpuset.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. #ifdef CONFIG_CPUSETS
  14. extern int number_of_cpusets; /* How many cpusets are defined in system? */
  15. extern int cpuset_init_early(void);
  16. extern int cpuset_init(void);
  17. extern void cpuset_init_smp(void);
  18. extern void cpuset_fork(struct task_struct *p);
  19. extern void cpuset_exit(struct task_struct *p);
  20. extern cpumask_t cpuset_cpus_allowed(struct task_struct *p);
  21. extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
  22. #define cpuset_current_mems_allowed (current->mems_allowed)
  23. void cpuset_init_current_mems_allowed(void);
  24. void cpuset_update_task_memory_state(void);
  25. #define cpuset_nodes_subset_current_mems_allowed(nodes) \
  26. nodes_subset((nodes), current->mems_allowed)
  27. int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
  28. extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask);
  29. extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask);
  30. static int inline cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  31. {
  32. return number_of_cpusets <= 1 ||
  33. __cpuset_zone_allowed_softwall(z, gfp_mask);
  34. }
  35. static int inline cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  36. {
  37. return number_of_cpusets <= 1 ||
  38. __cpuset_zone_allowed_hardwall(z, gfp_mask);
  39. }
  40. extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
  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. #else /* !CONFIG_CPUSETS */
  63. static inline int cpuset_init_early(void) { return 0; }
  64. static inline int cpuset_init(void) { return 0; }
  65. static inline void cpuset_init_smp(void) {}
  66. static inline void cpuset_fork(struct task_struct *p) {}
  67. static inline void cpuset_exit(struct task_struct *p) {}
  68. static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p)
  69. {
  70. return cpu_possible_map;
  71. }
  72. static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
  73. {
  74. return node_possible_map;
  75. }
  76. #define cpuset_current_mems_allowed (node_online_map)
  77. static inline void cpuset_init_current_mems_allowed(void) {}
  78. static inline void cpuset_update_task_memory_state(void) {}
  79. #define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
  80. static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
  81. {
  82. return 1;
  83. }
  84. static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
  85. {
  86. return 1;
  87. }
  88. static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
  89. {
  90. return 1;
  91. }
  92. static inline int cpuset_excl_nodes_overlap(const struct task_struct *p)
  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. #endif /* !CONFIG_CPUSETS */
  118. #endif /* _LINUX_CPUSET_H */