Re: [PATCH -next] sched/cputime: Fix the bug of reading time backward from /proc/stat

From: Li Hua
Date: Tue Aug 16 2022 - 07:30:54 EST


It's unreadable, I'm sorry about that.

The CPU statistics time read from /proc/stat should only be incremented. The bug
I found is that the value read latest is smaller than the former.

The root cause of the problem is that the "vtime->utime" and "delta" are temporarily
added to the stack and show to the user. The value of 'vtime->utime + delta' depends
on which task the CPU is executing. As bellow:
show_stat -> kcpustat_cpu_fetch -> kcpustat_cpu_fetch_vtime -> cpustat[CPUTIME_USER] += vtime->utime + delta