From 3a022fb0770712afc380929799b2ce27fd0a1dec Mon Sep 17 00:00:00 2001 From: Huaixin Chang Date: Mon, 1 Jun 2020 15:03:44 +0800 Subject: [PATCH 2117/2944] alinux: sched/fair: Fix CPU burst stat fix #28171040 If a cfs_rq is assigned some runtime in a previous period, and returns to global pool in the next period, cfs_b->runtime might be larger than cfs_b->pervious_runtime. In this case, the next period is idle. So do not count it as a burst period. Fixes: 53e31aed3f31 ("alinux: sched: Add cfs bandwidth burst statistics") Signed-off-by: Huaixin Chang Acked-by: Shanpei Chen --- kernel/sched/fair.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6aebd8e1..7efb936 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4387,10 +4387,12 @@ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b, u64 overrun) return; } - runtime = cfs_b->previous_runtime - cfs_b->runtime; - if (runtime > cfs_b->quota) { - cfs_b->burst_time += runtime - cfs_b->quota; - cfs_b->nr_burst++; + if (cfs_b->previous_runtime > cfs_b->runtime) { + runtime = cfs_b->previous_runtime - cfs_b->runtime; + if (runtime > cfs_b->quota) { + cfs_b->burst_time += runtime - cfs_b->quota; + cfs_b->nr_burst++; + } } cfs_b->current_buffer = max(cfs_b->runtime, cfs_b->buffer); -- 1.8.3.1