Skip to content

Commit 6e6558a

Browse files
committed
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 <[email protected]>
1 parent e4e149d commit 6e6558a

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

include/linux/sched/ext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,12 @@ static inline void print_scx_info(const char *log_lvl, struct task_struct *p) {}
214214
static inline void scx_softlockup(u32 dur_s) {}
215215

216216
#endif /* CONFIG_SCHED_CLASS_EXT */
217+
218+
struct scx_task_group {
219+
#ifdef CONFIG_EXT_GROUP_SCHED
220+
u32 flags; /* SCX_TG_* */
221+
u32 weight;
222+
#endif
223+
};
224+
217225
#endif /* _LINUX_SCHED_EXT_H */

kernel/sched/ext.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,32 +4058,32 @@ static bool scx_cgroup_enabled;
40584058

40594059
void scx_tg_init(struct task_group *tg)
40604060
{
4061-
tg->scx_weight = CGROUP_WEIGHT_DFL;
4061+
tg->scx.weight = CGROUP_WEIGHT_DFL;
40624062
}
40634063

40644064
int scx_tg_online(struct task_group *tg)
40654065
{
40664066
struct scx_sched *sch = scx_root;
40674067
int ret = 0;
40684068

4069-
WARN_ON_ONCE(tg->scx_flags & (SCX_TG_ONLINE | SCX_TG_INITED));
4069+
WARN_ON_ONCE(tg->scx.flags & (SCX_TG_ONLINE | SCX_TG_INITED));
40704070

40714071
percpu_down_read(&scx_cgroup_rwsem);
40724072

40734073
if (scx_cgroup_enabled) {
40744074
if (SCX_HAS_OP(sch, cgroup_init)) {
40754075
struct scx_cgroup_init_args args =
4076-
{ .weight = tg->scx_weight };
4076+
{ .weight = tg->scx.weight };
40774077

40784078
ret = SCX_CALL_OP_RET(sch, SCX_KF_UNLOCKED, cgroup_init,
40794079
NULL, tg->css.cgroup, &args);
40804080
if (ret)
40814081
ret = ops_sanitize_err(sch, "cgroup_init", ret);
40824082
}
40834083
if (ret == 0)
4084-
tg->scx_flags |= SCX_TG_ONLINE | SCX_TG_INITED;
4084+
tg->scx.flags |= SCX_TG_ONLINE | SCX_TG_INITED;
40854085
} else {
4086-
tg->scx_flags |= SCX_TG_ONLINE;
4086+
tg->scx.flags |= SCX_TG_ONLINE;
40874087
}
40884088

40894089
percpu_up_read(&scx_cgroup_rwsem);
@@ -4094,15 +4094,15 @@ void scx_tg_offline(struct task_group *tg)
40944094
{
40954095
struct scx_sched *sch = scx_root;
40964096

4097-
WARN_ON_ONCE(!(tg->scx_flags & SCX_TG_ONLINE));
4097+
WARN_ON_ONCE(!(tg->scx.flags & SCX_TG_ONLINE));
40984098

40994099
percpu_down_read(&scx_cgroup_rwsem);
41004100

41014101
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_exit) &&
4102-
(tg->scx_flags & SCX_TG_INITED))
4102+
(tg->scx.flags & SCX_TG_INITED))
41034103
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_exit, NULL,
41044104
tg->css.cgroup);
4105-
tg->scx_flags &= ~(SCX_TG_ONLINE | SCX_TG_INITED);
4105+
tg->scx.flags &= ~(SCX_TG_ONLINE | SCX_TG_INITED);
41064106

41074107
percpu_up_read(&scx_cgroup_rwsem);
41084108
}
@@ -4211,11 +4211,11 @@ void scx_group_set_weight(struct task_group *tg, unsigned long weight)
42114211
percpu_down_read(&scx_cgroup_rwsem);
42124212

42134213
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_set_weight) &&
4214-
tg->scx_weight != weight)
4214+
tg->scx.weight != weight)
42154215
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_set_weight, NULL,
42164216
tg_cgrp(tg), weight);
42174217

4218-
tg->scx_weight = weight;
4218+
tg->scx.weight = weight;
42194219

42204220
percpu_up_read(&scx_cgroup_rwsem);
42214221
}
@@ -4366,9 +4366,9 @@ static void scx_cgroup_exit(struct scx_sched *sch)
43664366
css_for_each_descendant_post(css, &root_task_group.css) {
43674367
struct task_group *tg = css_tg(css);
43684368

4369-
if (!(tg->scx_flags & SCX_TG_INITED))
4369+
if (!(tg->scx.flags & SCX_TG_INITED))
43704370
continue;
4371-
tg->scx_flags &= ~SCX_TG_INITED;
4371+
tg->scx.flags &= ~SCX_TG_INITED;
43724372

43734373
if (!sch->ops.cgroup_exit)
43744374
continue;
@@ -4400,14 +4400,14 @@ static int scx_cgroup_init(struct scx_sched *sch)
44004400
rcu_read_lock();
44014401
css_for_each_descendant_pre(css, &root_task_group.css) {
44024402
struct task_group *tg = css_tg(css);
4403-
struct scx_cgroup_init_args args = { .weight = tg->scx_weight };
4403+
struct scx_cgroup_init_args args = { .weight = tg->scx.weight };
44044404

4405-
if ((tg->scx_flags &
4405+
if ((tg->scx.flags &
44064406
(SCX_TG_ONLINE | SCX_TG_INITED)) != SCX_TG_ONLINE)
44074407
continue;
44084408

44094409
if (!sch->ops.cgroup_init) {
4410-
tg->scx_flags |= SCX_TG_INITED;
4410+
tg->scx.flags |= SCX_TG_INITED;
44114411
continue;
44124412
}
44134413

@@ -4422,7 +4422,7 @@ static int scx_cgroup_init(struct scx_sched *sch)
44224422
scx_error(sch, "ops.cgroup_init() failed (%d)", ret);
44234423
return ret;
44244424
}
4425-
tg->scx_flags |= SCX_TG_INITED;
4425+
tg->scx.flags |= SCX_TG_INITED;
44264426

44274427
rcu_read_lock();
44284428
css_put(css);

kernel/sched/sched.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,7 @@ struct task_group {
471471
struct rt_bandwidth rt_bandwidth;
472472
#endif
473473

474-
#ifdef CONFIG_EXT_GROUP_SCHED
475-
u32 scx_flags; /* SCX_TG_* */
476-
u32 scx_weight;
477-
#endif
474+
struct scx_task_group scx;
478475

479476
struct rcu_head rcu;
480477
struct list_head list;

0 commit comments

Comments
 (0)