From 1c5ab7a7f5d94fe1bb39e2aaa9343c0988192582 Mon Sep 17 00:00:00 2001 From: Yihao Wu Date: Wed, 20 May 2020 11:57:55 +0800 Subject: [PATCH] alinux: sched: Fix %steal in cpuacct.proc_stat in guest OS to #28143829 rq_clock_task is less than rq_clock when in VM, or when IRQ_TIME_ACCOUNTING is on. So they are not comparable when accounting elapsed time. This bug is not observed on host yet, because neither of these two conditions are met. Use rq_clock at both begin and end of exec_start_raw accumulation to fix this bug, because we expect steal% in cpuacct.proc_stat of VM's cgroups can reflect the cpu time the host steal from the guest. Fixes: c75529800bf2 ("alinux: sched: Introduce per-cgroup steal accounting") Signed-off-by: Yihao Wu Acked-by: Michael Wang --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ee99c2eeddbd..ddd5de3e1486 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1023,7 +1023,7 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) * We are starting a new run period: */ se->exec_start = rq_clock_task(rq_of(cfs_rq)); - se->exec_start_raw = rq_clock_task(rq_of(cfs_rq)); + se->exec_start_raw = rq_clock(rq_of(cfs_rq)); } /************************************************** -- GitLab