]>
Commit | Line | Data |
---|---|---|
5091faa4 MG |
1 | #ifdef CONFIG_SCHED_AUTOGROUP |
2 | ||
029632fb PZ |
3 | #include <linux/kref.h> |
4 | #include <linux/rwsem.h> | |
4eb5aaa3 | 5 | #include <linux/sched/autogroup.h> |
029632fb | 6 | |
5091faa4 | 7 | struct autogroup { |
c1ad41f1 IM |
8 | /* |
9 | * reference doesn't mean how many thread attach to this | |
10 | * autogroup now. It just stands for the number of task | |
11 | * could use this autogroup. | |
12 | */ | |
5091faa4 MG |
13 | struct kref kref; |
14 | struct task_group *tg; | |
15 | struct rw_semaphore lock; | |
16 | unsigned long id; | |
17 | int nice; | |
18 | }; | |
19 | ||
029632fb PZ |
20 | extern void autogroup_init(struct task_struct *init_task); |
21 | extern void autogroup_free(struct task_group *tg); | |
22 | ||
23 | static inline bool task_group_is_autogroup(struct task_group *tg) | |
24 | { | |
25 | return !!tg->autogroup; | |
26 | } | |
27 | ||
28 | extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg); | |
29 | ||
5091faa4 | 30 | static inline struct task_group * |
029632fb PZ |
31 | autogroup_task_group(struct task_struct *p, struct task_group *tg) |
32 | { | |
316c1608 | 33 | int enabled = READ_ONCE(sysctl_sched_autogroup_enabled); |
c1ad41f1 IM |
34 | |
35 | if (enabled && task_wants_autogroup(p, tg)) | |
029632fb PZ |
36 | return p->signal->autogroup->tg; |
37 | ||
38 | return tg; | |
39 | } | |
40 | ||
41 | extern int autogroup_path(struct task_group *tg, char *buf, int buflen); | |
5091faa4 MG |
42 | |
43 | #else /* !CONFIG_SCHED_AUTOGROUP */ | |
44 | ||
45 | static inline void autogroup_init(struct task_struct *init_task) { } | |
46 | static inline void autogroup_free(struct task_group *tg) { } | |
f4493771 MG |
47 | static inline bool task_group_is_autogroup(struct task_group *tg) |
48 | { | |
49 | return 0; | |
50 | } | |
5091faa4 MG |
51 | |
52 | static inline struct task_group * | |
53 | autogroup_task_group(struct task_struct *p, struct task_group *tg) | |
54 | { | |
55 | return tg; | |
56 | } | |
57 | ||
58 | #ifdef CONFIG_SCHED_DEBUG | |
59 | static inline int autogroup_path(struct task_group *tg, char *buf, int buflen) | |
60 | { | |
61 | return 0; | |
62 | } | |
63 | #endif | |
64 | ||
65 | #endif /* CONFIG_SCHED_AUTOGROUP */ |