Skip to content

Commit e179e80

Browse files
committed
sched: Introduce CONFIG_GROUP_SCHED_WEIGHT
sched_ext will soon add cgroup cpu.weigh support. The cgroup interface code is currently gated behind CONFIG_FAIR_GROUP_SCHED. As the fair class and/or SCX may implement the feature, put the interface code behind the new CONFIG_CGROUP_SCHED_WEIGHT which is selected by CONFIG_FAIR_GROUP_SCHED. This allows either sched class to enable the itnerface code without ading more complex CONFIG tests. When !CONFIG_FAIR_GROUP_SCHED, a dummy version of sched_group_set_shares() is added to support later CONFIG_CGROUP_SCHED_WEIGHT && !CONFIG_FAIR_GROUP_SCHED builds. No functional changes. Signed-off-by: Tejun Heo <[email protected]>
1 parent 41082c1 commit e179e80

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

init/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,9 +1024,13 @@ menuconfig CGROUP_SCHED
10241024
tasks.
10251025

10261026
if CGROUP_SCHED
1027+
config GROUP_SCHED_WEIGHT
1028+
def_bool n
1029+
10271030
config FAIR_GROUP_SCHED
10281031
bool "Group scheduling for SCHED_OTHER"
10291032
depends on CGROUP_SCHED
1033+
select GROUP_SCHED_WEIGHT
10301034
default CGROUP_SCHED
10311035

10321036
config CFS_BANDWIDTH

kernel/sched/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9193,7 +9193,7 @@ static int cpu_uclamp_max_show(struct seq_file *sf, void *v)
91939193
}
91949194
#endif /* CONFIG_UCLAMP_TASK_GROUP */
91959195

9196-
#ifdef CONFIG_FAIR_GROUP_SCHED
9196+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
91979197
static unsigned long tg_weight(struct task_group *tg)
91989198
{
91999199
return scale_load_down(tg->shares);
@@ -9212,6 +9212,7 @@ static u64 cpu_shares_read_u64(struct cgroup_subsys_state *css,
92129212
{
92139213
return tg_weight(css_tg(css));
92149214
}
9215+
#endif /* CONFIG_GROUP_SCHED_WEIGHT */
92159216

92169217
#ifdef CONFIG_CFS_BANDWIDTH
92179218
static DEFINE_MUTEX(cfs_constraints_mutex);
@@ -9557,7 +9558,6 @@ static int cpu_cfs_local_stat_show(struct seq_file *sf, void *v)
95579558
return 0;
95589559
}
95599560
#endif /* CONFIG_CFS_BANDWIDTH */
9560-
#endif /* CONFIG_FAIR_GROUP_SCHED */
95619561

95629562
#ifdef CONFIG_RT_GROUP_SCHED
95639563
static int cpu_rt_runtime_write(struct cgroup_subsys_state *css,
@@ -9585,7 +9585,7 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css,
95859585
}
95869586
#endif /* CONFIG_RT_GROUP_SCHED */
95879587

9588-
#ifdef CONFIG_FAIR_GROUP_SCHED
9588+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
95899589
static s64 cpu_idle_read_s64(struct cgroup_subsys_state *css,
95909590
struct cftype *cft)
95919591
{
@@ -9600,7 +9600,7 @@ static int cpu_idle_write_s64(struct cgroup_subsys_state *css,
96009600
#endif
96019601

96029602
static struct cftype cpu_legacy_files[] = {
9603-
#ifdef CONFIG_FAIR_GROUP_SCHED
9603+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
96049604
{
96059605
.name = "shares",
96069606
.read_u64 = cpu_shares_read_u64,
@@ -9710,7 +9710,7 @@ static int cpu_local_stat_show(struct seq_file *sf,
97109710
return 0;
97119711
}
97129712

9713-
#ifdef CONFIG_FAIR_GROUP_SCHED
9713+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
97149714

97159715
static u64 cpu_weight_read_u64(struct cgroup_subsys_state *css,
97169716
struct cftype *cft)
@@ -9764,7 +9764,7 @@ static int cpu_weight_nice_write_s64(struct cgroup_subsys_state *css,
97649764

97659765
return sched_group_set_shares(css_tg(css), scale_load(weight));
97669766
}
9767-
#endif
9767+
#endif /* CONFIG_GROUP_SCHED_WEIGHT */
97689768

97699769
static void __maybe_unused cpu_period_quota_print(struct seq_file *sf,
97709770
long period, long quota)
@@ -9824,7 +9824,7 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of,
98249824
#endif
98259825

98269826
static struct cftype cpu_files[] = {
9827-
#ifdef CONFIG_FAIR_GROUP_SCHED
9827+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
98289828
{
98299829
.name = "weight",
98309830
.flags = CFTYPE_NOT_ON_ROOT,

kernel/sched/sched.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ struct task_group {
483483

484484
};
485485

486-
#ifdef CONFIG_FAIR_GROUP_SCHED
486+
#ifdef CONFIG_GROUP_SCHED_WEIGHT
487487
#define ROOT_TASK_GROUP_LOAD NICE_0_LOAD
488488

489489
/*
@@ -575,6 +575,8 @@ extern void set_task_rq_fair(struct sched_entity *se,
575575
static inline void set_task_rq_fair(struct sched_entity *se,
576576
struct cfs_rq *prev, struct cfs_rq *next) { }
577577
#endif /* CONFIG_SMP */
578+
#else /* !CONFIG_FAIR_GROUP_SCHED */
579+
static inline int sched_group_set_shares(struct task_group *tg, unsigned long shares) { return 0; }
578580
#endif /* CONFIG_FAIR_GROUP_SCHED */
579581

580582
#else /* CONFIG_CGROUP_SCHED */

0 commit comments

Comments
 (0)