sched_ext, sched/core: Factor out struct scx_task_group
More sched_ext fields will be added to struct task_group. In preparation, factor out sched_ext fields into struct scx_task_group to reduce clutter in the common header. No functional changes. Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
e4e149dd2f
commit
6e6558a6bc
|
@ -214,4 +214,12 @@ static inline void print_scx_info(const char *log_lvl, struct task_struct *p) {}
|
||||||
static inline void scx_softlockup(u32 dur_s) {}
|
static inline void scx_softlockup(u32 dur_s) {}
|
||||||
|
|
||||||
#endif /* CONFIG_SCHED_CLASS_EXT */
|
#endif /* CONFIG_SCHED_CLASS_EXT */
|
||||||
|
|
||||||
|
struct scx_task_group {
|
||||||
|
#ifdef CONFIG_EXT_GROUP_SCHED
|
||||||
|
u32 flags; /* SCX_TG_* */
|
||||||
|
u32 weight;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _LINUX_SCHED_EXT_H */
|
#endif /* _LINUX_SCHED_EXT_H */
|
||||||
|
|
|
@ -4058,7 +4058,7 @@ static bool scx_cgroup_enabled;
|
||||||
|
|
||||||
void scx_tg_init(struct task_group *tg)
|
void scx_tg_init(struct task_group *tg)
|
||||||
{
|
{
|
||||||
tg->scx_weight = CGROUP_WEIGHT_DFL;
|
tg->scx.weight = CGROUP_WEIGHT_DFL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scx_tg_online(struct task_group *tg)
|
int scx_tg_online(struct task_group *tg)
|
||||||
|
@ -4066,14 +4066,14 @@ int scx_tg_online(struct task_group *tg)
|
||||||
struct scx_sched *sch = scx_root;
|
struct scx_sched *sch = scx_root;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
WARN_ON_ONCE(tg->scx_flags & (SCX_TG_ONLINE | SCX_TG_INITED));
|
WARN_ON_ONCE(tg->scx.flags & (SCX_TG_ONLINE | SCX_TG_INITED));
|
||||||
|
|
||||||
percpu_down_read(&scx_cgroup_rwsem);
|
percpu_down_read(&scx_cgroup_rwsem);
|
||||||
|
|
||||||
if (scx_cgroup_enabled) {
|
if (scx_cgroup_enabled) {
|
||||||
if (SCX_HAS_OP(sch, cgroup_init)) {
|
if (SCX_HAS_OP(sch, cgroup_init)) {
|
||||||
struct scx_cgroup_init_args args =
|
struct scx_cgroup_init_args args =
|
||||||
{ .weight = tg->scx_weight };
|
{ .weight = tg->scx.weight };
|
||||||
|
|
||||||
ret = SCX_CALL_OP_RET(sch, SCX_KF_UNLOCKED, cgroup_init,
|
ret = SCX_CALL_OP_RET(sch, SCX_KF_UNLOCKED, cgroup_init,
|
||||||
NULL, tg->css.cgroup, &args);
|
NULL, tg->css.cgroup, &args);
|
||||||
|
@ -4081,9 +4081,9 @@ int scx_tg_online(struct task_group *tg)
|
||||||
ret = ops_sanitize_err(sch, "cgroup_init", ret);
|
ret = ops_sanitize_err(sch, "cgroup_init", ret);
|
||||||
}
|
}
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
tg->scx_flags |= SCX_TG_ONLINE | SCX_TG_INITED;
|
tg->scx.flags |= SCX_TG_ONLINE | SCX_TG_INITED;
|
||||||
} else {
|
} else {
|
||||||
tg->scx_flags |= SCX_TG_ONLINE;
|
tg->scx.flags |= SCX_TG_ONLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
percpu_up_read(&scx_cgroup_rwsem);
|
percpu_up_read(&scx_cgroup_rwsem);
|
||||||
|
@ -4094,15 +4094,15 @@ void scx_tg_offline(struct task_group *tg)
|
||||||
{
|
{
|
||||||
struct scx_sched *sch = scx_root;
|
struct scx_sched *sch = scx_root;
|
||||||
|
|
||||||
WARN_ON_ONCE(!(tg->scx_flags & SCX_TG_ONLINE));
|
WARN_ON_ONCE(!(tg->scx.flags & SCX_TG_ONLINE));
|
||||||
|
|
||||||
percpu_down_read(&scx_cgroup_rwsem);
|
percpu_down_read(&scx_cgroup_rwsem);
|
||||||
|
|
||||||
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_exit) &&
|
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_exit) &&
|
||||||
(tg->scx_flags & SCX_TG_INITED))
|
(tg->scx.flags & SCX_TG_INITED))
|
||||||
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_exit, NULL,
|
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_exit, NULL,
|
||||||
tg->css.cgroup);
|
tg->css.cgroup);
|
||||||
tg->scx_flags &= ~(SCX_TG_ONLINE | SCX_TG_INITED);
|
tg->scx.flags &= ~(SCX_TG_ONLINE | SCX_TG_INITED);
|
||||||
|
|
||||||
percpu_up_read(&scx_cgroup_rwsem);
|
percpu_up_read(&scx_cgroup_rwsem);
|
||||||
}
|
}
|
||||||
|
@ -4211,11 +4211,11 @@ void scx_group_set_weight(struct task_group *tg, unsigned long weight)
|
||||||
percpu_down_read(&scx_cgroup_rwsem);
|
percpu_down_read(&scx_cgroup_rwsem);
|
||||||
|
|
||||||
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_set_weight) &&
|
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_set_weight) &&
|
||||||
tg->scx_weight != weight)
|
tg->scx.weight != weight)
|
||||||
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_set_weight, NULL,
|
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_set_weight, NULL,
|
||||||
tg_cgrp(tg), weight);
|
tg_cgrp(tg), weight);
|
||||||
|
|
||||||
tg->scx_weight = weight;
|
tg->scx.weight = weight;
|
||||||
|
|
||||||
percpu_up_read(&scx_cgroup_rwsem);
|
percpu_up_read(&scx_cgroup_rwsem);
|
||||||
}
|
}
|
||||||
|
@ -4366,9 +4366,9 @@ static void scx_cgroup_exit(struct scx_sched *sch)
|
||||||
css_for_each_descendant_post(css, &root_task_group.css) {
|
css_for_each_descendant_post(css, &root_task_group.css) {
|
||||||
struct task_group *tg = css_tg(css);
|
struct task_group *tg = css_tg(css);
|
||||||
|
|
||||||
if (!(tg->scx_flags & SCX_TG_INITED))
|
if (!(tg->scx.flags & SCX_TG_INITED))
|
||||||
continue;
|
continue;
|
||||||
tg->scx_flags &= ~SCX_TG_INITED;
|
tg->scx.flags &= ~SCX_TG_INITED;
|
||||||
|
|
||||||
if (!sch->ops.cgroup_exit)
|
if (!sch->ops.cgroup_exit)
|
||||||
continue;
|
continue;
|
||||||
|
@ -4400,14 +4400,14 @@ static int scx_cgroup_init(struct scx_sched *sch)
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
css_for_each_descendant_pre(css, &root_task_group.css) {
|
css_for_each_descendant_pre(css, &root_task_group.css) {
|
||||||
struct task_group *tg = css_tg(css);
|
struct task_group *tg = css_tg(css);
|
||||||
struct scx_cgroup_init_args args = { .weight = tg->scx_weight };
|
struct scx_cgroup_init_args args = { .weight = tg->scx.weight };
|
||||||
|
|
||||||
if ((tg->scx_flags &
|
if ((tg->scx.flags &
|
||||||
(SCX_TG_ONLINE | SCX_TG_INITED)) != SCX_TG_ONLINE)
|
(SCX_TG_ONLINE | SCX_TG_INITED)) != SCX_TG_ONLINE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!sch->ops.cgroup_init) {
|
if (!sch->ops.cgroup_init) {
|
||||||
tg->scx_flags |= SCX_TG_INITED;
|
tg->scx.flags |= SCX_TG_INITED;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4422,7 +4422,7 @@ static int scx_cgroup_init(struct scx_sched *sch)
|
||||||
scx_error(sch, "ops.cgroup_init() failed (%d)", ret);
|
scx_error(sch, "ops.cgroup_init() failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
tg->scx_flags |= SCX_TG_INITED;
|
tg->scx.flags |= SCX_TG_INITED;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
css_put(css);
|
css_put(css);
|
||||||
|
|
|
@ -471,10 +471,7 @@ struct task_group {
|
||||||
struct rt_bandwidth rt_bandwidth;
|
struct rt_bandwidth rt_bandwidth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_EXT_GROUP_SCHED
|
struct scx_task_group scx;
|
||||||
u32 scx_flags; /* SCX_TG_* */
|
|
||||||
u32 scx_weight;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct rcu_head rcu;
|
struct rcu_head rcu;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
|
Loading…
Reference in New Issue