Skip to content

Commit c5c55a7

Browse files
committed
sched/core: Reorganize cgroup bandwidth control interface file reads
JIRA: https://issues.redhat.com/browse/RHEL-110301 commit 43e33f5 Author: Tejun Heo <tj@kernel.org> Date: Fri Jun 13 15:23:29 2025 -1000 sched/core: Reorganize cgroup bandwidth control interface file reads - Update tg_get_cfs_*() to return u64 values. These are now used as the low level accessors to the fair's bandwidth configuration parameters. Translation to usecs takes place in these functions. - Add tg_bandwidth() which reads all three bandwidth parameters using tg_get_cfs_*(). - Reimplement cgroup interface read functions using tg_bandwidth(). Drop cfs from the function names. This is to prepare for adding bandwidth control support to sched_ext. tg_bandwidth() will be used as the muxing point similar to tg_weight(). No functional changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20250614012346.2358261-4-tj@kernel.org Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent ec2d2d2 commit c5c55a7

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

kernel/sched/core.c

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9414,7 +9414,7 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota,
94149414
return 0;
94159415
}
94169416

9417-
static long tg_get_cfs_period(struct task_group *tg)
9417+
static u64 tg_get_cfs_period(struct task_group *tg)
94189418
{
94199419
u64 cfs_period_us;
94209420

@@ -9424,20 +9424,20 @@ static long tg_get_cfs_period(struct task_group *tg)
94249424
return cfs_period_us;
94259425
}
94269426

9427-
static long tg_get_cfs_quota(struct task_group *tg)
9427+
static u64 tg_get_cfs_quota(struct task_group *tg)
94289428
{
94299429
u64 quota_us;
94309430

94319431
if (tg->cfs_bandwidth.quota == RUNTIME_INF)
9432-
return -1;
9432+
return RUNTIME_INF;
94339433

94349434
quota_us = tg->cfs_bandwidth.quota;
94359435
do_div(quota_us, NSEC_PER_USEC);
94369436

94379437
return quota_us;
94389438
}
94399439

9440-
static long tg_get_cfs_burst(struct task_group *tg)
9440+
static u64 tg_get_cfs_burst(struct task_group *tg)
94419441
{
94429442
u64 burst_us;
94439443

@@ -9624,22 +9624,42 @@ static int cpu_cfs_local_stat_show(struct seq_file *sf, void *v)
96249624
return 0;
96259625
}
96269626

9627-
static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css,
9628-
struct cftype *cft)
9627+
static void tg_bandwidth(struct task_group *tg,
9628+
u64 *period_us_p, u64 *quota_us_p, u64 *burst_us_p)
96299629
{
9630-
return tg_get_cfs_period(css_tg(css));
9630+
if (period_us_p)
9631+
*period_us_p = tg_get_cfs_period(tg);
9632+
if (quota_us_p)
9633+
*quota_us_p = tg_get_cfs_quota(tg);
9634+
if (burst_us_p)
9635+
*burst_us_p = tg_get_cfs_burst(tg);
96319636
}
96329637

9633-
static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css,
9634-
struct cftype *cft)
9638+
static u64 cpu_period_read_u64(struct cgroup_subsys_state *css,
9639+
struct cftype *cft)
96359640
{
9636-
return tg_get_cfs_quota(css_tg(css));
9641+
u64 period_us;
9642+
9643+
tg_bandwidth(css_tg(css), &period_us, NULL, NULL);
9644+
return period_us;
96379645
}
96389646

9639-
static u64 cpu_cfs_burst_read_u64(struct cgroup_subsys_state *css,
9640-
struct cftype *cft)
9647+
static s64 cpu_quota_read_s64(struct cgroup_subsys_state *css,
9648+
struct cftype *cft)
96419649
{
9642-
return tg_get_cfs_burst(css_tg(css));
9650+
u64 quota_us;
9651+
9652+
tg_bandwidth(css_tg(css), NULL, &quota_us, NULL);
9653+
return quota_us; /* (s64)RUNTIME_INF becomes -1 */
9654+
}
9655+
9656+
static u64 cpu_burst_read_u64(struct cgroup_subsys_state *css,
9657+
struct cftype *cft)
9658+
{
9659+
u64 burst_us;
9660+
9661+
tg_bandwidth(css_tg(css), NULL, NULL, &burst_us);
9662+
return burst_us;
96439663
}
96449664

96459665
static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css,
@@ -9722,17 +9742,17 @@ static struct cftype cpu_legacy_files[] = {
97229742
#ifdef CONFIG_CFS_BANDWIDTH
97239743
{
97249744
.name = "cfs_period_us",
9725-
.read_u64 = cpu_cfs_period_read_u64,
9745+
.read_u64 = cpu_period_read_u64,
97269746
.write_u64 = cpu_cfs_period_write_u64,
97279747
},
97289748
{
97299749
.name = "cfs_quota_us",
9730-
.read_s64 = cpu_cfs_quota_read_s64,
9750+
.read_s64 = cpu_quota_read_s64,
97319751
.write_s64 = cpu_cfs_quota_write_s64,
97329752
},
97339753
{
97349754
.name = "cfs_burst_us",
9735-
.read_u64 = cpu_cfs_burst_read_u64,
9755+
.read_u64 = cpu_burst_read_u64,
97369756
.write_u64 = cpu_cfs_burst_write_u64,
97379757
},
97389758
{
@@ -9954,8 +9974,10 @@ static int __maybe_unused cpu_period_quota_parse(char *buf,
99549974
static int cpu_max_show(struct seq_file *sf, void *v)
99559975
{
99569976
struct task_group *tg = css_tg(seq_css(sf));
9977+
u64 period_us, quota_us;
99579978

9958-
cpu_period_quota_print(sf, tg_get_cfs_period(tg), tg_get_cfs_quota(tg));
9979+
tg_bandwidth(tg, &period_us, &quota_us, NULL);
9980+
cpu_period_quota_print(sf, period_us, quota_us);
99599981
return 0;
99609982
}
99619983

@@ -10006,7 +10028,7 @@ static struct cftype cpu_files[] = {
1000610028
{
1000710029
.name = "max.burst",
1000810030
.flags = CFTYPE_NOT_ON_ROOT,
10009-
.read_u64 = cpu_cfs_burst_read_u64,
10031+
.read_u64 = cpu_burst_read_u64,
1001010032
.write_u64 = cpu_cfs_burst_write_u64,
1001110033
},
1001210034
#endif /* CONFIG_CFS_BANDWIDTH */

0 commit comments

Comments
 (0)