]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - kernel/sched/autogroup.h
Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into...
[mirror_ubuntu-artful-kernel.git] / kernel / sched / autogroup.h
CommitLineData
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 7struct 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
20extern void autogroup_init(struct task_struct *init_task);
21extern void autogroup_free(struct task_group *tg);
22
23static inline bool task_group_is_autogroup(struct task_group *tg)
24{
25 return !!tg->autogroup;
26}
27
28extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
29
5091faa4 30static inline struct task_group *
029632fb
PZ
31autogroup_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
41extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
5091faa4
MG
42
43#else /* !CONFIG_SCHED_AUTOGROUP */
44
45static inline void autogroup_init(struct task_struct *init_task) { }
46static inline void autogroup_free(struct task_group *tg) { }
f4493771
MG
47static inline bool task_group_is_autogroup(struct task_group *tg)
48{
49 return 0;
50}
5091faa4
MG
51
52static inline struct task_group *
53autogroup_task_group(struct task_struct *p, struct task_group *tg)
54{
55 return tg;
56}
57
58#ifdef CONFIG_SCHED_DEBUG
59static 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 */