Add statistics and document for cfs bandwidth burst
Subsystems (3)
cover Add statistics and document for cfs bandwidth burst
The comparison in __refill_cfs_bandwidth_runtime is further simplified.
Huaixin Chang (2):
sched/fair: Add cfs bandwidth burst statistics sched/fair: Add document for burstable CFS bandwidth
Documentation/admin-guide/cgroup-v2.rst | 8 ++++ Documentation/scheduler/sched-bwc.rst | 85 +++++++++++++++++++++++++++++---- kernel/sched/core.c | 13 +++-- kernel/sched/fair.c | 9 ++++ kernel/sched/sched.h | 3 ++ 5 files changed, 105 insertions(+), 13 deletions(-)
Signature · 1 line
2.14.4.44.g2045bb6
PATCH 1/2 sched/fair: Add cfs bandwidth burst statistics
Two new statistics are introduced to show the internal of burst feature and explain why burst helps or not.
nr_bursts: number of periods bandwidth burst occurs burst_usec: cumulative wall-time that any cpus has
used above quota in respective periods
--- kernel/sched/core.c | 13 ++++++++++--- kernel/sched/fair.c | 9 +++++++++ kernel/sched/sched.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-)
kernel/sched/core.c +10 -3
@@ -10088,6 +10088,9 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v) seq_printf(sf, "wait_sum %llu\n", ws); } +seq_printf (sf,"nr_bursts %d\n" , cfs_b->nr_burst); +seq_printf (sf,"burst_usec %llu\n" , cfs_b->burst_time); +return 0 ; }#endif /* CONFIG_CFS_BANDWIDTH */
@@ -10184,16 +10187,20 @@ static int cpu_extra_stat_show(struct seq_file *sf, {struct task_group *tg =css_tg (css);struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; -u64 throttled_usec; +u64 throttled_usec, burst_usec; throttled_usec = cfs_b->throttled_time;do_div (throttled_usec,NSEC_PER_USEC ); + burst_usec = cfs_b->burst_time; +do_div (burst_usec,NSEC_PER_USEC );seq_printf (sf,"nr_periods %d\n" "nr_throttled %d\n" -"throttled_usec %llu\n" , +"throttled_usec %llu\n" +"nr_bursts %d\n" +"burst_usec %llu\n" , cfs_b->nr_periods, cfs_b->nr_throttled, - throttled_usec); + throttled_usec, cfs_b->nr_burst, burst_usec); }#endif return 0 ;
kernel/sched/fair.c +9 -0
@@ -4655,11 +4655,20 @@ static inline u64 sched_cfs_bandwidth_slice(void)*/ void __refill_cfs_bandwidth_runtime (struct cfs_bandwidth *cfs_b) { +s64 runtime; +if (unlikely (cfs_b->quota ==RUNTIME_INF ))return ; cfs_b->runtime += cfs_b->quota; + runtime = cfs_b->runtime_snap - cfs_b->runtime; +if (runtime >0 ) { + cfs_b->burst_time += runtime; + cfs_b->nr_burst++; + } + cfs_b->runtime =min (cfs_b->runtime, cfs_b->quota + cfs_b->burst); + cfs_b->runtime_snap = cfs_b->runtime; }static inline struct cfs_bandwidth *tg_cfs_bandwidth (struct task_group *tg)
kernel/sched/sched.h +3 -0
@@ -367,6 +367,7 @@ struct cfs_bandwidth {u64 quota;u64 runtime;u64 burst; +u64 runtime_snap;s64 hierarchical_quota;u8 idle;
@@ -379,7 +380,9 @@ struct cfs_bandwidth {/* Statistics: */ int nr_periods;int nr_throttled; +int nr_burst;u64 throttled_time; +u64 burst_time;#endif };
Signature · 1 line
2.14.4.44.g2045bb6
Re: [PATCH 1/2] sched/fair: Add cfs bandwidth burst statistics
Quoted 24 lines · Huaixin Chang
Two new statistics are introduced to show the internal of burst feature and explain why burst helps or not.
nr_bursts: number of periods bandwidth burst occurs burst_usec: cumulative wall-time that any cpus hasused above quota in respective periods
Co-developed-by Shanpei Chen <[email protected]>Signed-off-by Shanpei Chen <[email protected]>Co-developed-by Tianchen Ding <[email protected]>Signed-off-by Tianchen Ding <[email protected]>Signed-off-by Huaixin Chang <[email protected]>Acked-by Tejun Heo <[email protected]>--- kernel/sched/core.c | 13 ++++++++++--- kernel/sched/fair.c | 9 +++++++++ kernel/sched/sched.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-)kernel/sched/core.c +0
-0
kernel/sched/core.c static int cpu_cfs_stat_show(struct seq_file *sf, void *v) · line 10092
Quoted 5 lines
kernel/sched/core.c +2
-0@@ -10088,6 +10088,9 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)seq_printf (sf,"wait_sum %llu\n" , ws); } +seq_printf (sf,"nr_bursts %d\n" , cfs_b->nr_burst); +seq_printf (sf,"burst_usec %llu\n" , cfs_b->burst_time);
burst_time is nsec, not usec.
Just "burst_time" seems the way to go for consistency with throttled_time in the same file, though "burst_usec" nicely has units and would have the same name between cgroup1 and 2.
Tejun Heo
maintainerRe: [PATCH 1/2] sched/fair: Add cfs bandwidth burst statistics
Quoted 5 lines · Daniel Jordan
burst_timeis nsec, not usec.Just "
burst_time" seems the way to go for consistency withthrottled_timein the same file, though "burst_usec" nicely has units and would have the same name between cgroup1 and 2.
The cgroup2 interface rule is that time units are in usecs. The right thing to do is keeping the _usec postfix (to avoid confusion due to the unit change from cgroup1) and converting it to usecs for printing.
Thanks.
Signature · 1 line
tejun
PATCH 2/2 sched/fair: Add document for burstable CFS bandwidth
In reply to Huaixin ChangBasic description of usage and effect for CFS Bandwidth Control Burst.
--- Documentation/admin-guide/cgroup-v2.rst | 8 ++++ Documentation/scheduler/sched-bwc.rst | 85 +++++++++++++++++++++++++++++---- 2 files changed, 83 insertions(+), 10 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +8 -0
@@ -1016,6 +1016,8 @@ All time durations are in microseconds. - nr_periods - nr_throttled - throttled_usec + - nr_bursts + - burst_usec cpu.weight A read-write single value file which exists on non-root
@@ -1047,6 +1049,12 @@ All time durations are in microseconds. $PERIOD duration. "max" for $MAX indicates no limit. If only one number is written, $MAX is updated. + cpu.max.burst + A read-write single value file which exists on non-root + cgroups. The default is "0". + + The burst in the range [0, $QUOTA]. + cpu.pressure A read-write nested-keyed file.
Documentation/scheduler/sched-bwc.rst +75 -10
130 lines not on this page · raw message
Signature · 1 line
2.14.4.44.g2045bb6
Re: [PATCH 2/2] sched/fair: Add document for burstable CFS bandwidth
Documentation/admin-guide/cgroup-v2.rst All time durations are in microseconds. · line 1056
Quoted 13 lines · Huaixin Chang
Documentation/admin-guide/cgroup-v2.rst +5
-0@@ -1047,6 +1049,12 @@ All time durations are in microseconds. $PERIOD duration. "max" for $MAX indicates no limit. If only one number is written, $MAX is updated. + cpu.max.burst + A read-write single value file which exists on non-root + cgroups. The default is "0". + + The burst in the range [0, $QUOTA].
FWIW, max/$MAX are used in this file instead of quota, so it seems clearer to stick to that.