aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/auto_group.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched/auto_group.h')
-rw-r--r--kernel/sched/auto_group.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/kernel/sched/auto_group.h b/kernel/sched/auto_group.h
new file mode 100644
index 000000000000..8bd047142816
--- /dev/null
+++ b/kernel/sched/auto_group.h
@@ -0,0 +1,64 @@
1#ifdef CONFIG_SCHED_AUTOGROUP
2
3#include <linux/kref.h>
4#include <linux/rwsem.h>
5
6struct autogroup {
7 /*
8 * reference doesn't mean how many thread attach to this
9 * autogroup now. It just stands for the number of task
10 * could use this autogroup.
11 */
12 struct kref kref;
13 struct task_group *tg;
14 struct rw_semaphore lock;
15 unsigned long id;
16 int nice;
17};
18
19extern void autogroup_init(struct task_struct *init_task);
20extern void autogroup_free(struct task_group *tg);
21
22static inline bool task_group_is_autogroup(struct task_group *tg)
23{
24 return !!tg->autogroup;
25}
26
27extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
28
29static inline struct task_group *
30autogroup_task_group(struct task_struct *p, struct task_group *tg)
31{
32 int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
33
34 if (enabled && task_wants_autogroup(p, tg))
35 return p->signal->autogroup->tg;
36
37 return tg;
38}
39
40extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
41
42#else /* !CONFIG_SCHED_AUTOGROUP */
43
44static inline void autogroup_init(struct task_struct *init_task) { }
45static inline void autogroup_free(struct task_group *tg) { }
46static inline bool task_group_is_autogroup(struct task_group *tg)
47{
48 return 0;
49}
50
51static inline struct task_group *
52autogroup_task_group(struct task_struct *p, struct task_group *tg)
53{
54 return tg;
55}
56
57#ifdef CONFIG_SCHED_DEBUG
58static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
59{
60 return 0;
61}
62#endif
63
64#endif /* CONFIG_SCHED_AUTOGROUP */