auto_group.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if (task_wants_autogroup(p, tg))
  22. return p->signal->autogroup->tg;
  23. return tg;
  24. }
  25. extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
  26. #else /* !CONFIG_SCHED_AUTOGROUP */
  27. static inline void autogroup_init(struct task_struct *init_task) { }
  28. static inline void autogroup_free(struct task_group *tg) { }
  29. static inline bool task_group_is_autogroup(struct task_group *tg)
  30. {
  31. return 0;
  32. }
  33. static inline struct task_group *
  34. autogroup_task_group(struct task_struct *p, struct task_group *tg)
  35. {
  36. return tg;
  37. }
  38. #ifdef CONFIG_SCHED_DEBUG
  39. static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
  40. {
  41. return 0;
  42. }
  43. #endif
  44. #endif /* CONFIG_SCHED_AUTOGROUP */