Merge tag 'char-misc-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[linux/fpc-iii.git] / kernel / sched / auto_group.h
blob8bd047142816dea81894bb27ccc3c78a38ac3d61
1 #ifdef CONFIG_SCHED_AUTOGROUP
3 #include <linux/kref.h>
4 #include <linux/rwsem.h>
6 struct autogroup {
7 /*
8 * reference doesn't mean how many thread attach to this
9 * autogroup now. It just stands for the number of task
10 * could use this autogroup.
12 struct kref kref;
13 struct task_group *tg;
14 struct rw_semaphore lock;
15 unsigned long id;
16 int nice;
19 extern void autogroup_init(struct task_struct *init_task);
20 extern void autogroup_free(struct task_group *tg);
22 static inline bool task_group_is_autogroup(struct task_group *tg)
24 return !!tg->autogroup;
27 extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
29 static inline struct task_group *
30 autogroup_task_group(struct task_struct *p, struct task_group *tg)
32 int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
34 if (enabled && task_wants_autogroup(p, tg))
35 return p->signal->autogroup->tg;
37 return tg;
40 extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
42 #else /* !CONFIG_SCHED_AUTOGROUP */
44 static inline void autogroup_init(struct task_struct *init_task) { }
45 static inline void autogroup_free(struct task_group *tg) { }
46 static inline bool task_group_is_autogroup(struct task_group *tg)
48 return 0;
51 static inline struct task_group *
52 autogroup_task_group(struct task_struct *p, struct task_group *tg)
54 return tg;
57 #ifdef CONFIG_SCHED_DEBUG
58 static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
60 return 0;
62 #endif
64 #endif /* CONFIG_SCHED_AUTOGROUP */