Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Tejun Heo and committed by
Peter Zijlstra
43e33f53 de4c80c6

+40 -18
+40 -18
kernel/sched/core.c
··· 9404 9404 return 0; 9405 9405 } 9406 9406 9407 - static long tg_get_cfs_period(struct task_group *tg) 9407 + static u64 tg_get_cfs_period(struct task_group *tg) 9408 9408 { 9409 9409 u64 cfs_period_us; 9410 9410 ··· 9414 9414 return cfs_period_us; 9415 9415 } 9416 9416 9417 - static long tg_get_cfs_quota(struct task_group *tg) 9417 + static u64 tg_get_cfs_quota(struct task_group *tg) 9418 9418 { 9419 9419 u64 quota_us; 9420 9420 9421 9421 if (tg->cfs_bandwidth.quota == RUNTIME_INF) 9422 - return -1; 9422 + return RUNTIME_INF; 9423 9423 9424 9424 quota_us = tg->cfs_bandwidth.quota; 9425 9425 do_div(quota_us, NSEC_PER_USEC); ··· 9427 9427 return quota_us; 9428 9428 } 9429 9429 9430 - static long tg_get_cfs_burst(struct task_group *tg) 9430 + static u64 tg_get_cfs_burst(struct task_group *tg) 9431 9431 { 9432 9432 u64 burst_us; 9433 9433 ··· 9614 9614 return 0; 9615 9615 } 9616 9616 9617 - static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css, 9618 - struct cftype *cft) 9617 + static void tg_bandwidth(struct task_group *tg, 9618 + u64 *period_us_p, u64 *quota_us_p, u64 *burst_us_p) 9619 9619 { 9620 - return tg_get_cfs_period(css_tg(css)); 9620 + if (period_us_p) 9621 + *period_us_p = tg_get_cfs_period(tg); 9622 + if (quota_us_p) 9623 + *quota_us_p = tg_get_cfs_quota(tg); 9624 + if (burst_us_p) 9625 + *burst_us_p = tg_get_cfs_burst(tg); 9621 9626 } 9622 9627 9623 - static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css, 9624 - struct cftype *cft) 9628 + static u64 cpu_period_read_u64(struct cgroup_subsys_state *css, 9629 + struct cftype *cft) 9625 9630 { 9626 - return tg_get_cfs_quota(css_tg(css)); 9631 + u64 period_us; 9632 + 9633 + tg_bandwidth(css_tg(css), &period_us, NULL, NULL); 9634 + return period_us; 9627 9635 } 9628 9636 9629 - static u64 cpu_cfs_burst_read_u64(struct cgroup_subsys_state *css, 9630 - struct cftype *cft) 9637 + static s64 cpu_quota_read_s64(struct cgroup_subsys_state *css, 9638 + struct cftype *cft) 9631 9639 { 9632 - return tg_get_cfs_burst(css_tg(css)); 9640 + u64 quota_us; 9641 + 9642 + tg_bandwidth(css_tg(css), NULL, &quota_us, NULL); 9643 + return quota_us; /* (s64)RUNTIME_INF becomes -1 */ 9644 + } 9645 + 9646 + static u64 cpu_burst_read_u64(struct cgroup_subsys_state *css, 9647 + struct cftype *cft) 9648 + { 9649 + u64 burst_us; 9650 + 9651 + tg_bandwidth(css_tg(css), NULL, NULL, &burst_us); 9652 + return burst_us; 9633 9653 } 9634 9654 9635 9655 static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css, ··· 9732 9712 #ifdef CONFIG_CFS_BANDWIDTH 9733 9713 { 9734 9714 .name = "cfs_period_us", 9735 - .read_u64 = cpu_cfs_period_read_u64, 9715 + .read_u64 = cpu_period_read_u64, 9736 9716 .write_u64 = cpu_cfs_period_write_u64, 9737 9717 }, 9738 9718 { 9739 9719 .name = "cfs_quota_us", 9740 - .read_s64 = cpu_cfs_quota_read_s64, 9720 + .read_s64 = cpu_quota_read_s64, 9741 9721 .write_s64 = cpu_cfs_quota_write_s64, 9742 9722 }, 9743 9723 { 9744 9724 .name = "cfs_burst_us", 9745 - .read_u64 = cpu_cfs_burst_read_u64, 9725 + .read_u64 = cpu_burst_read_u64, 9746 9726 .write_u64 = cpu_cfs_burst_write_u64, 9747 9727 }, 9748 9728 { ··· 9964 9944 static int cpu_max_show(struct seq_file *sf, void *v) 9965 9945 { 9966 9946 struct task_group *tg = css_tg(seq_css(sf)); 9947 + u64 period_us, quota_us; 9967 9948 9968 - cpu_period_quota_print(sf, tg_get_cfs_period(tg), tg_get_cfs_quota(tg)); 9949 + tg_bandwidth(tg, &period_us, &quota_us, NULL); 9950 + cpu_period_quota_print(sf, period_us, quota_us); 9969 9951 return 0; 9970 9952 } 9971 9953 ··· 10018 9996 { 10019 9997 .name = "max.burst", 10020 9998 .flags = CFTYPE_NOT_ON_ROOT, 10021 - .read_u64 = cpu_cfs_burst_read_u64, 9999 + .read_u64 = cpu_burst_read_u64, 10022 10000 .write_u64 = cpu_cfs_burst_write_u64, 10023 10001 }, 10024 10002 #endif /* CONFIG_CFS_BANDWIDTH */