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: Relocate tg_get_cfs_*() and cpu_cfs_*_read_*()

Collect the getters, relocate the trivial interface file wrappers, and put
all of them in period, quota, burst order to prepare for future changes.
Pure reordering. 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-3-tj@kernel.org

authored by

Tejun Heo and committed by
Peter Zijlstra
de4c80c6 d403a368

+67 -67
+67 -67
kernel/sched/core.c
··· 9404 9404 return 0; 9405 9405 } 9406 9406 9407 - static int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us) 9407 + static long tg_get_cfs_period(struct task_group *tg) 9408 9408 { 9409 - u64 quota, period, burst; 9409 + u64 cfs_period_us; 9410 9410 9411 - period = ktime_to_ns(tg->cfs_bandwidth.period); 9412 - burst = tg->cfs_bandwidth.burst; 9413 - if (cfs_quota_us < 0) 9414 - quota = RUNTIME_INF; 9415 - else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC) 9416 - quota = (u64)cfs_quota_us * NSEC_PER_USEC; 9417 - else 9418 - return -EINVAL; 9411 + cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.period); 9412 + do_div(cfs_period_us, NSEC_PER_USEC); 9419 9413 9420 - return tg_set_cfs_bandwidth(tg, period, quota, burst); 9414 + return cfs_period_us; 9421 9415 } 9422 9416 9423 9417 static long tg_get_cfs_quota(struct task_group *tg) ··· 9425 9431 do_div(quota_us, NSEC_PER_USEC); 9426 9432 9427 9433 return quota_us; 9434 + } 9435 + 9436 + static long tg_get_cfs_burst(struct task_group *tg) 9437 + { 9438 + u64 burst_us; 9439 + 9440 + burst_us = tg->cfs_bandwidth.burst; 9441 + do_div(burst_us, NSEC_PER_USEC); 9442 + 9443 + return burst_us; 9428 9444 } 9429 9445 9430 9446 static int tg_set_cfs_period(struct task_group *tg, long cfs_period_us) ··· 9451 9447 return tg_set_cfs_bandwidth(tg, period, quota, burst); 9452 9448 } 9453 9449 9454 - static long tg_get_cfs_period(struct task_group *tg) 9450 + static int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us) 9455 9451 { 9456 - u64 cfs_period_us; 9452 + u64 quota, period, burst; 9457 9453 9458 - cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.period); 9459 - do_div(cfs_period_us, NSEC_PER_USEC); 9454 + period = ktime_to_ns(tg->cfs_bandwidth.period); 9455 + burst = tg->cfs_bandwidth.burst; 9456 + if (cfs_quota_us < 0) 9457 + quota = RUNTIME_INF; 9458 + else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC) 9459 + quota = (u64)cfs_quota_us * NSEC_PER_USEC; 9460 + else 9461 + return -EINVAL; 9460 9462 9461 - return cfs_period_us; 9463 + return tg_set_cfs_bandwidth(tg, period, quota, burst); 9462 9464 } 9463 9465 9464 9466 static int tg_set_cfs_burst(struct task_group *tg, long cfs_burst_us) ··· 9479 9469 quota = tg->cfs_bandwidth.quota; 9480 9470 9481 9471 return tg_set_cfs_bandwidth(tg, period, quota, burst); 9482 - } 9483 - 9484 - static long tg_get_cfs_burst(struct task_group *tg) 9485 - { 9486 - u64 burst_us; 9487 - 9488 - burst_us = tg->cfs_bandwidth.burst; 9489 - do_div(burst_us, NSEC_PER_USEC); 9490 - 9491 - return burst_us; 9492 - } 9493 - 9494 - static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css, 9495 - struct cftype *cft) 9496 - { 9497 - return tg_get_cfs_quota(css_tg(css)); 9498 - } 9499 - 9500 - static int cpu_cfs_quota_write_s64(struct cgroup_subsys_state *css, 9501 - struct cftype *cftype, s64 cfs_quota_us) 9502 - { 9503 - return tg_set_cfs_quota(css_tg(css), cfs_quota_us); 9504 - } 9505 - 9506 - static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css, 9507 - struct cftype *cft) 9508 - { 9509 - return tg_get_cfs_period(css_tg(css)); 9510 - } 9511 - 9512 - static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css, 9513 - struct cftype *cftype, u64 cfs_period_us) 9514 - { 9515 - return tg_set_cfs_period(css_tg(css), cfs_period_us); 9516 - } 9517 - 9518 - static u64 cpu_cfs_burst_read_u64(struct cgroup_subsys_state *css, 9519 - struct cftype *cft) 9520 - { 9521 - return tg_get_cfs_burst(css_tg(css)); 9522 - } 9523 - 9524 - static int cpu_cfs_burst_write_u64(struct cgroup_subsys_state *css, 9525 - struct cftype *cftype, u64 cfs_burst_us) 9526 - { 9527 - return tg_set_cfs_burst(css_tg(css), cfs_burst_us); 9528 9472 } 9529 9473 9530 9474 struct cfs_schedulable_data { ··· 9613 9649 9614 9650 return 0; 9615 9651 } 9652 + 9653 + static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css, 9654 + struct cftype *cft) 9655 + { 9656 + return tg_get_cfs_period(css_tg(css)); 9657 + } 9658 + 9659 + static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css, 9660 + struct cftype *cft) 9661 + { 9662 + return tg_get_cfs_quota(css_tg(css)); 9663 + } 9664 + 9665 + static u64 cpu_cfs_burst_read_u64(struct cgroup_subsys_state *css, 9666 + struct cftype *cft) 9667 + { 9668 + return tg_get_cfs_burst(css_tg(css)); 9669 + } 9670 + 9671 + static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css, 9672 + struct cftype *cftype, u64 cfs_period_us) 9673 + { 9674 + return tg_set_cfs_period(css_tg(css), cfs_period_us); 9675 + } 9676 + 9677 + static int cpu_cfs_quota_write_s64(struct cgroup_subsys_state *css, 9678 + struct cftype *cftype, s64 cfs_quota_us) 9679 + { 9680 + return tg_set_cfs_quota(css_tg(css), cfs_quota_us); 9681 + } 9682 + 9683 + static int cpu_cfs_burst_write_u64(struct cgroup_subsys_state *css, 9684 + struct cftype *cftype, u64 cfs_burst_us) 9685 + { 9686 + return tg_set_cfs_burst(css_tg(css), cfs_burst_us); 9687 + } 9616 9688 #endif /* CONFIG_CFS_BANDWIDTH */ 9617 9689 9618 9690 #ifdef CONFIG_RT_GROUP_SCHED ··· 9711 9711 #endif 9712 9712 #ifdef CONFIG_CFS_BANDWIDTH 9713 9713 { 9714 - .name = "cfs_quota_us", 9715 - .read_s64 = cpu_cfs_quota_read_s64, 9716 - .write_s64 = cpu_cfs_quota_write_s64, 9717 - }, 9718 - { 9719 9714 .name = "cfs_period_us", 9720 9715 .read_u64 = cpu_cfs_period_read_u64, 9721 9716 .write_u64 = cpu_cfs_period_write_u64, 9717 + }, 9718 + { 9719 + .name = "cfs_quota_us", 9720 + .read_s64 = cpu_cfs_quota_read_s64, 9721 + .write_s64 = cpu_cfs_quota_write_s64, 9722 9722 }, 9723 9723 { 9724 9724 .name = "cfs_burst_us",