]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - kernel/sched/autogroup.h
Merge tag 'acpi-5.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[thirdparty/kernel/stable.git] / kernel / sched / autogroup.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
5091faa4
MG
2#ifdef CONFIG_SCHED_AUTOGROUP
3
4struct autogroup {
c1ad41f1 5 /*
97fb7a0a
IM
6 * Reference doesn't mean how many threads attach to this
7 * autogroup now. It just stands for the number of tasks
8 * which could use this autogroup.
c1ad41f1 9 */
5091faa4
MG
10 struct kref kref;
11 struct task_group *tg;
12 struct rw_semaphore lock;
13 unsigned long id;
14 int nice;
15};
16
029632fb
PZ
17extern void autogroup_init(struct task_struct *init_task);
18extern void autogroup_free(struct task_group *tg);
19
20static inline bool task_group_is_autogroup(struct task_group *tg)
21{
22 return !!tg->autogroup;
23}
24
25extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
26
5091faa4 27static inline struct task_group *
029632fb
PZ
28autogroup_task_group(struct task_struct *p, struct task_group *tg)
29{
316c1608 30 int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);
c1ad41f1
IM
31
32 if (enabled && task_wants_autogroup(p, tg))
029632fb
PZ
33 return p->signal->autogroup->tg;
34
35 return tg;
36}
37
38extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
5091faa4
MG
39
40#else /* !CONFIG_SCHED_AUTOGROUP */
41
42static inline void autogroup_init(struct task_struct *init_task) { }
43static inline void autogroup_free(struct task_group *tg) { }
f4493771
MG
44static inline bool task_group_is_autogroup(struct task_group *tg)
45{
46 return 0;
47}
5091faa4
MG
48
49static inline struct task_group *
50autogroup_task_group(struct task_struct *p, struct task_group *tg)
51{
52 return tg;
53}
54
5091faa4
MG
55static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
56{
57 return 0;
58}
5091faa4
MG
59
60#endif /* CONFIG_SCHED_AUTOGROUP */