sched/group_sched: add task_group_is_root() api
PATCH 1/1 sched/group_sched: add task_group_is_root() api
Use task_group_is_root() instead of '!tg->se[0]'
and 'tg == &root_task_group' to judge whether atask_group is root_task_group.
Signed-off-by Hui Su <[email protected]>
--- kernel/sched/autogroup.c | 2 +- kernel/sched/core.c | 11 ++++++++--- kernel/sched/fair.c | 4 ++-- kernel/sched/rt.c | 2 +- kernel/sched/sched.h | 2 ++ 5 files changed, 14 insertions(+), 7 deletions(-)
kernel/sched/autogroup.c +1 -1
@@ -106,7 +106,7 @@ static inline struct autogroup *autogroup_create(void)bool task_wants_autogroup (struct task_struct *p,struct task_group *tg) { -if (tg != &root_task_group) +if (!task_group_is_root (tg))return false;/* * If we race with autogroup_move_group() the caller can use the old
kernel/sched/core.c +8 -3
@@ -1075,7 +1075,7 @@ uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)*/ if (task_group_is_autogroup (task_group (p)))return uc_req; -if (task_group (p) == &root_task_group) +if (task_group_is_root (task_group (p)))return uc_req; uc_max =task_group (p)->uclamp[clamp_id];
@@ -7574,6 +7574,11 @@ void sched_move_task(struct task_struct *tsk)task_rq_unlock (rq, tsk, &rf); } +bool task_group_is_root (struct task_group *tg) +{ +return tg == &root_task_group; +} +static inline struct task_group *css_tg (struct cgroup_subsys_state *css) { return css ? container_of(css, struct task_group, css) : NULL;
@@ -7894,7 +7899,7 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)int i, ret =0 , runtime_enabled, runtime_was_enabled;struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; -if (tg == &root_task_group) +if (task_group_is_root (tg))return -EINVAL ;/*
@@ -8138,7 +8143,7 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)seq_printf (sf,"nr_throttled %d\n" , cfs_b->nr_throttled);seq_printf (sf,"throttled_time %llu\n" , cfs_b->throttled_time); -if (schedstat_enabled () && tg != &root_task_group) { +if (schedstat_enabled () && !task_group_is_root (tg)) {u64 ws =0 ;int i;
kernel/sched/fair.c +2 -2
@@ -3311,7 +3311,7 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq)/* * No need to update load_avg for root_task_group as it is not used. */ -if (cfs_rq->tg == &root_task_group) +if (task_group_is_root (cfs_rq->tg))return ;if (abs (delta) > cfs_rq->tg_load_avg_contrib /64 ) {
@@ -11095,7 +11095,7 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)/* * We can't change the weight of the root cgroup. */ -if (!tg->se[0 ]) +if (task_group_is_root (tg))return -EINVAL ; shares =clamp (shares,scale_load (MIN_SHARES ),scale_load (MAX_SHARES ));
kernel/sched/rt.c +1 -1
@@ -2580,7 +2580,7 @@ static int tg_set_rt_bandwidth(struct task_group *tg,* Disallowing the root group RT runtime is BAD, it would disallow the * kernel creating (and or operating) RT threads. */ -if (tg == &root_task_group && rt_runtime ==0 ) +if (task_group_is_root (tg) && rt_runtime ==0 )return -EINVAL ;/* No period doesn't make any sense. */
kernel/sched/sched.h +2 -0
@@ -497,6 +497,8 @@ extern void sched_offline_group(struct task_group *tg);extern void sched_move_task (struct task_struct *tsk); +extern bool task_group_is_root (struct task_group *tg); +#ifdef CONFIG_FAIR_GROUP_SCHED extern int sched_group_set_shares (struct task_group *tg,unsigned long shares);
Signature · 1 line
2.25.1