Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _KERNEL_SCHED_AUTOGROUP_H
0003 #define _KERNEL_SCHED_AUTOGROUP_H
0004 
0005 #ifdef CONFIG_SCHED_AUTOGROUP
0006 
0007 struct autogroup {
0008     /*
0009      * Reference doesn't mean how many threads attach to this
0010      * autogroup now. It just stands for the number of tasks
0011      * which could use this autogroup.
0012      */
0013     struct kref     kref;
0014     struct task_group   *tg;
0015     struct rw_semaphore lock;
0016     unsigned long       id;
0017     int         nice;
0018 };
0019 
0020 extern void autogroup_init(struct task_struct *init_task);
0021 extern void autogroup_free(struct task_group *tg);
0022 
0023 static inline bool task_group_is_autogroup(struct task_group *tg)
0024 {
0025     return !!tg->autogroup;
0026 }
0027 
0028 extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
0029 
0030 static inline struct task_group *
0031 autogroup_task_group(struct task_struct *p, struct task_group *tg)
0032 {
0033     extern unsigned int sysctl_sched_autogroup_enabled;
0034     int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);
0035 
0036     if (enabled && task_wants_autogroup(p, tg))
0037         return p->signal->autogroup->tg;
0038 
0039     return tg;
0040 }
0041 
0042 extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
0043 
0044 #else /* !CONFIG_SCHED_AUTOGROUP */
0045 
0046 static inline void autogroup_init(struct task_struct *init_task) {  }
0047 static inline void autogroup_free(struct task_group *tg) { }
0048 static inline bool task_group_is_autogroup(struct task_group *tg)
0049 {
0050     return 0;
0051 }
0052 
0053 static inline struct task_group *
0054 autogroup_task_group(struct task_struct *p, struct task_group *tg)
0055 {
0056     return tg;
0057 }
0058 
0059 static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
0060 {
0061     return 0;
0062 }
0063 
0064 #endif /* CONFIG_SCHED_AUTOGROUP */
0065 
0066 #endif /* _KERNEL_SCHED_AUTOGROUP_H */