From: Xie XiuQi xiexiuqi@huawei.com
hulk inclusion category: bugfix bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=37 CVE: NA
If we enable 'use_sched_idle_time' at commend line, when possile cpus > online cpus, we get the uncorrected idle time. Return the pervious sum_idle_time to avoid this issue.
Signed-off-by: Xie XiuQi xiexiuqi@huawei.com Tested-by: Yu Xiangyang yuxiangyang4@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- kernel/sched/cputime.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 159e4c467773..8dd27c1fbb29 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -649,6 +649,10 @@ unsigned long long sched_get_idle_time(int cpu) struct rq_cputime *rt = &per_cpu(rq_cputimes, cpu); u64 hi = 0, si = 0;
+ /* Do not update cpu time when cpu offline */ + if (!cpu_online(cpu)) + return rt->sum_idle_time; + #ifdef CONFIG_IRQ_TIME_ACCOUNTING if (sched_clock_irqtime) { hi = kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ_IDLE];