Skip to content

Commit 3f4b6c1

Browse files
changhuaixinmngyadam
authored andcommitted
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_time: cumulative wall-time (in nanoseconds) that any cpus has used above quota in respective periods Co-developed-by: Shanpei Chen <shanpeic@linux.alibaba.com> Signed-off-by: Shanpei Chen <shanpeic@linux.alibaba.com> Co-developed-by: Tianchen Ding <dtcccc@linux.alibaba.com> Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com> Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20210830032215.16302-2-changhuaixin@linux.alibaba.com
1 parent 0720482 commit 3f4b6c1

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

kernel/sched/core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10585,6 +10585,9 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)
1058510585
seq_printf(sf, "wait_sum %llu\n", ws);
1058610586
}
1058710587

10588+
seq_printf(sf, "nr_bursts %d\n", cfs_b->nr_burst);
10589+
seq_printf(sf, "burst_time %llu\n", cfs_b->burst_time);
10590+
1058810591
return 0;
1058910592
}
1059010593
#endif /* CONFIG_CFS_BANDWIDTH */
@@ -10700,16 +10703,20 @@ static int cpu_extra_stat_show(struct seq_file *sf,
1070010703
{
1070110704
struct task_group *tg = css_tg(css);
1070210705
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
10703-
u64 throttled_usec;
10706+
u64 throttled_usec, burst_usec;
1070410707

1070510708
throttled_usec = cfs_b->throttled_time;
1070610709
do_div(throttled_usec, NSEC_PER_USEC);
10710+
burst_usec = cfs_b->burst_time;
10711+
do_div(burst_usec, NSEC_PER_USEC);
1070710712

1070810713
seq_printf(sf, "nr_periods %d\n"
1070910714
"nr_throttled %d\n"
10710-
"throttled_usec %llu\n",
10715+
"throttled_usec %llu\n"
10716+
"nr_bursts %d\n"
10717+
"burst_usec %llu\n",
1071110718
cfs_b->nr_periods, cfs_b->nr_throttled,
10712-
throttled_usec);
10719+
throttled_usec, cfs_b->nr_burst, burst_usec);
1071310720
}
1071410721
#endif
1071510722
return 0;

kernel/sched/fair.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4880,11 +4880,20 @@ static inline u64 sched_cfs_bandwidth_slice(void)
48804880
*/
48814881
void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b)
48824882
{
4883+
s64 runtime;
4884+
48834885
if (unlikely(cfs_b->quota == RUNTIME_INF))
48844886
return;
48854887

48864888
cfs_b->runtime += cfs_b->quota;
4889+
runtime = cfs_b->runtime_snap - cfs_b->runtime;
4890+
if (runtime > 0) {
4891+
cfs_b->burst_time += runtime;
4892+
cfs_b->nr_burst++;
4893+
}
4894+
48874895
cfs_b->runtime = min(cfs_b->runtime, cfs_b->quota + cfs_b->burst);
4896+
cfs_b->runtime_snap = cfs_b->runtime;
48884897
}
48894898

48904899
static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg)

kernel/sched/sched.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ struct cfs_bandwidth {
368368
u64 quota;
369369
u64 runtime;
370370
u64 burst;
371+
u64 runtime_snap;
371372
s64 hierarchical_quota;
372373

373374
u8 idle;
@@ -380,7 +381,9 @@ struct cfs_bandwidth {
380381
/* Statistics: */
381382
int nr_periods;
382383
int nr_throttled;
384+
int nr_burst;
383385
u64 throttled_time;
386+
u64 burst_time;
384387
#endif
385388
};
386389

0 commit comments

Comments
 (0)