From: Xie XiuQi xiexiuqi@huawei.com
hulk inclusion category: bugfix bugzilla: 46892 CVE: NA
Add get_idle_time stub function when CONFIG_PROC_FS disabled, to avoid this compile error.
$ make tinyconfig && make
kernel/sched/cputime.o: In function `sched_idle_time_adjust': cputime.c:(.text+0x3bb): undefined reference to `get_idle_time' make: *** [vmlinux] Error 1
Signed-off-by: Xie XiuQi xiexiuqi@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- include/linux/sched/cputime.h | 5 +++++ kernel/sched/cputime.c | 6 ++++++ 2 files changed, 11 insertions(+)
diff --git a/include/linux/sched/cputime.h b/include/linux/sched/cputime.h index 1ebbeec02051..6b1793606fc9 100644 --- a/include/linux/sched/cputime.h +++ b/include/linux/sched/cputime.h @@ -189,6 +189,11 @@ task_sched_runtime(struct task_struct *task); extern int use_sched_idle_time; extern int sched_idle_time_adjust(int cpu, u64 *utime, u64 *stime); extern unsigned long long sched_get_idle_time(int cpu); + +#ifdef CONFIG_PROC_FS extern u64 get_idle_time(int cpu); +#else +static inline u64 get_idle_time(int cpu) { return -1ULL; } +#endif
#endif /* _LINUX_SCHED_CPUTIME_H */ diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index a10b51259b6a..159e4c467773 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -593,6 +593,12 @@ int sched_idle_time_adjust(int cpu, u64 *utime, u64 *stime)
raw_spin_lock(&rq_cputime->lock);
+ /* If failed to get idle time, drop adjustment */ + if (get_idle_time(cpu) == -1ULL) { + raw_spin_unlock(&rq_cputime->lock); + return 0; + } + #ifdef CONFIG_IRQ_TIME_ACCOUNTING if (sched_clock_irqtime) { hi = kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ];