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>
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.
15 struct task_group
*tg
;
16 struct rw_semaphore lock
;
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
;
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
)
53 static inline struct task_group
*
54 autogroup_task_group(struct task_struct
*p
, struct task_group
*tg
)
59 #ifdef CONFIG_SCHED_DEBUG
60 static inline int autogroup_path(struct task_group
*tg
, char *buf
, int buflen
)
66 #endif /* CONFIG_SCHED_AUTOGROUP */