blob: 443232ebbb53b24ea369ca3c4fbb7b53c5e8cbef [file] [log] [blame]
Mike Galbraith5091faa2010-11-30 14:18:03 +01001#ifdef CONFIG_SCHED_AUTOGROUP
2
Peter Zijlstra029632f2011-10-25 10:00:11 +02003#include <linux/kref.h>
4#include <linux/rwsem.h>
5
Mike Galbraith5091faa2010-11-30 14:18:03 +01006struct autogroup {
7 struct kref kref;
8 struct task_group *tg;
9 struct rw_semaphore lock;
10 unsigned long id;
11 int nice;
12};
13
Peter Zijlstra029632f2011-10-25 10:00:11 +020014extern void autogroup_init(struct task_struct *init_task);
15extern void autogroup_free(struct task_group *tg);
16
17static inline bool task_group_is_autogroup(struct task_group *tg)
18{
19 return !!tg->autogroup;
20}
21
22extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
23
Mike Galbraith5091faa2010-11-30 14:18:03 +010024static inline struct task_group *
Peter Zijlstra029632f2011-10-25 10:00:11 +020025autogroup_task_group(struct task_struct *p, struct task_group *tg)
26{
27 int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
28
29 if (enabled && task_wants_autogroup(p, tg))
30 return p->signal->autogroup->tg;
31
32 return tg;
33}
34
35extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
Mike Galbraith5091faa2010-11-30 14:18:03 +010036
37#else /* !CONFIG_SCHED_AUTOGROUP */
38
39static inline void autogroup_init(struct task_struct *init_task) { }
40static inline void autogroup_free(struct task_group *tg) { }
Mike Galbraithf4493772011-01-13 04:54:50 +010041static inline bool task_group_is_autogroup(struct task_group *tg)
42{
43 return 0;
44}
Mike Galbraith5091faa2010-11-30 14:18:03 +010045
46static inline struct task_group *
47autogroup_task_group(struct task_struct *p, struct task_group *tg)
48{
49 return tg;
50}
51
52#ifdef CONFIG_SCHED_DEBUG
53static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
54{
55 return 0;
56}
57#endif
58
59#endif /* CONFIG_SCHED_AUTOGROUP */