Linux 4.15.6
[linux/fpc-iii.git] / kernel / sched / autogroup.h
blob27cd22b8982405c5ef2f07c7c4ff50314d220f36
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifdef CONFIG_SCHED_AUTOGROUP
4 #include <linux/kref.h>
5 #include <linux/rwsem.h>
6 #include <linux/sched/autogroup.h>
8 struct autogroup {
9 /*
10 * reference doesn't mean how many thread attach to this
11 * autogroup now. It just stands for the number of task
12 * could use this autogroup.
14 struct kref kref;
15 struct task_group *tg;
16 struct rw_semaphore lock;
17 unsigned long id;
18 int nice;
21 extern void autogroup_init(struct task_struct *init_task);
22 extern void autogroup_free(struct task_group *tg);
24 static inline bool task_group_is_autogroup(struct task_group *tg)
26 return !!tg->autogroup;
29 extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
31 static inline struct task_group *
32 autogroup_task_group(struct task_struct *p, struct task_group *tg)
34 int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);
36 if (enabled && task_wants_autogroup(p, tg))
37 return p->signal->autogroup->tg;
39 return tg;
42 extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
44 #else /* !CONFIG_SCHED_AUTOGROUP */
46 static inline void autogroup_init(struct task_struct *init_task) { }
47 static inline void autogroup_free(struct task_group *tg) { }
48 static inline bool task_group_is_autogroup(struct task_group *tg)
50 return 0;
53 static inline struct task_group *
54 autogroup_task_group(struct task_struct *p, struct task_group *tg)
56 return tg;
59 #ifdef CONFIG_SCHED_DEBUG
60 static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
62 return 0;
64 #endif
66 #endif /* CONFIG_SCHED_AUTOGROUP */