cpuset.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. 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(struct zone *z, gfp_t gfp_mask);
  28. static int inline cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
  29. {
  30. return number_of_cpusets <= 1 || __cpuset_zone_allowed(z, gfp_mask);
  31. }
  32. extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
  33. #define cpuset_memory_pressure_bump() \
  34. do { \
  35. if (cpuset_memory_pressure_enabled) \
  36. __cpuset_memory_pressure_bump(); \
  37. } while (0)
  38. extern int cpuset_memory_pressure_enabled;
  39. extern void __cpuset_memory_pressure_bump(void);
  40. extern struct file_operations proc_cpuset_operations;
  41. extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
  42. extern void cpuset_lock(void);
  43. extern void cpuset_unlock(void);
  44. extern int cpuset_mem_spread_node(void);
  45. static inline int cpuset_do_page_mem_spread(void)
  46. {
  47. return current->flags & PF_SPREAD_PAGE;
  48. }
  49. static inline int cpuset_do_slab_mem_spread(void)
  50. {
  51. return current->flags & PF_SPREAD_SLAB;
  52. }
  53. #else /* !CONFIG_CPUSETS */
  54. static inline int cpuset_init_early(void) { return 0; }
  55. static inline int cpuset_init(void) { return 0; }
  56. static inline void cpuset_init_smp(void) {}
  57. static inline void cpuset_fork(struct task_struct *p) {}
  58. static inline void cpuset_exit(struct task_struct *p) {}
  59. static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p)
  60. {
  61. return cpu_possible_map;
  62. }
  63. static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
  64. {
  65. return node_possible_map;
  66. }
  67. static inline void cpuset_init_current_mems_allowed(void) {}
  68. static inline void cpuset_update_task_memory_state(void) {}
  69. #define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
  70. static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
  71. {
  72. return 1;
  73. }
  74. static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
  75. {
  76. return 1;
  77. }
  78. static inline int cpuset_excl_nodes_overlap(const struct task_struct *p)
  79. {
  80. return 1;
  81. }
  82. static inline void cpuset_memory_pressure_bump(void) {}
  83. static inline char *cpuset_task_status_allowed(struct task_struct *task,
  84. char *buffer)
  85. {
  86. return buffer;
  87. }
  88. static inline void cpuset_lock(void) {}
  89. static inline void cpuset_unlock(void) {}
  90. static inline int cpuset_mem_spread_node(void)
  91. {
  92. return 0;
  93. }
  94. static inline int cpuset_do_page_mem_spread(void)
  95. {
  96. return 0;
  97. }
  98. static inline int cpuset_do_slab_mem_spread(void)
  99. {
  100. return 0;
  101. }
  102. #endif /* !CONFIG_CPUSETS */
  103. #endif /* _LINUX_CPUSET_H */