]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - kernel/sched/auto_group.h
Merge tag 'cputime-adjustment-cleanups' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / kernel / sched / auto_group.h
1 #ifdef CONFIG_SCHED_AUTOGROUP
2
3 #include <linux/kref.h>
4 #include <linux/rwsem.h>
5
6 struct autogroup {
7         struct kref             kref;
8         struct task_group       *tg;
9         struct rw_semaphore     lock;
10         unsigned long           id;
11         int                     nice;
12 };
13
14 extern void autogroup_init(struct task_struct *init_task);
15 extern void autogroup_free(struct task_group *tg);
16
17 static inline bool task_group_is_autogroup(struct task_group *tg)
18 {
19         return !!tg->autogroup;
20 }
21
22 extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
23
24 static inline struct task_group *
25 autogroup_task_group(struct task_struct *p, struct task_group *tg)
26 {
27         if (task_wants_autogroup(p, tg))
28                 return p->signal->autogroup->tg;
29
30         return tg;
31 }
32
33 extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
34
35 #else /* !CONFIG_SCHED_AUTOGROUP */
36
37 static inline void autogroup_init(struct task_struct *init_task) {  }
38 static inline void autogroup_free(struct task_group *tg) { }
39 static inline bool task_group_is_autogroup(struct task_group *tg)
40 {
41         return 0;
42 }
43
44 static inline struct task_group *
45 autogroup_task_group(struct task_struct *p, struct task_group *tg)
46 {
47         return tg;
48 }
49
50 #ifdef CONFIG_SCHED_DEBUG
51 static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
52 {
53         return 0;
54 }
55 #endif
56
57 #endif /* CONFIG_SCHED_AUTOGROUP */