auto_group.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifdef CONFIG_SCHED_AUTOGROUP
  2. #include <linux/kref.h>
  3. #include <linux/rwsem.h>
  4. struct autogroup {
  5. struct kref kref;
  6. struct task_group *tg;
  7. struct rw_semaphore lock;
  8. unsigned long id;
  9. int nice;
  10. };
  11. extern void autogroup_init(struct task_struct *init_task);
  12. extern void autogroup_free(struct task_group *tg);
  13. static inline bool task_group_is_autogroup(struct task_group *tg)
  14. {
  15. return !!tg->autogroup;
  16. }
  17. extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
  18. static inline struct task_group *
  19. autogroup_task_group(struct task_struct *p, struct task_group *tg)
  20. {
  21. int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
  22. if (enabled && task_wants_autogroup(p, tg))
  23. return p->signal->autogroup->tg;
  24. return tg;
  25. }
  26. extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
  27. #else /* !CONFIG_SCHED_AUTOGROUP */
  28. static inline void autogroup_init(struct task_struct *init_task) { }
  29. static inline void autogroup_free(struct task_group *tg) { }
  30. static inline bool task_group_is_autogroup(struct task_group *tg)
  31. {
  32. return 0;
  33. }
  34. static inline struct task_group *
  35. autogroup_task_group(struct task_struct *p, struct task_group *tg)
  36. {
  37. return tg;
  38. }
  39. #ifdef CONFIG_SCHED_DEBUG
  40. static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
  41. {
  42. return 0;
  43. }
  44. #endif
  45. #endif /* CONFIG_SCHED_AUTOGROUP */