Messages in this thread | | | Date | Fri, 30 Sep 2022 14:16:34 +0200 | From | Frederic Weisbecker <> | Subject | Re: [PATCH -next] sched/cputime: Fix the time backward issue about /proc/stat |
| |
On Fri, Sep 30, 2022 at 10:43:58AM +0800, zhengzucheng wrote: > > 在 2022/9/28 20:11, Frederic Weisbecker 写道: > > @@ -1024,20 +1045,20 @@ static int kcpustat_cpu_fetch_vtime(struct kernel_cpustat *dst, > > * add pending nohz time to the right place. > > */ > > if (state == VTIME_SYS) { > > - cpustat[CPUTIME_SYSTEM] += vtime->stime + delta; > > + cpustat[CPUTIME_SYSTEM] += delta; > > } else if (state == VTIME_USER) { > > if (task_nice(tsk) > 0) > > - cpustat[CPUTIME_NICE] += vtime->utime + delta; > > + cpustat[CPUTIME_NICE] += delta; > > else > > - cpustat[CPUTIME_USER] += vtime->utime + delta; > > + cpustat[CPUTIME_USER] += delta; > “delta” has the same problem as vtime->utime, which varies with different > tasks. switching between different tasks may cause time statistics to be > reversed.
I'm a bit confused, can you provide an example?
Thanks.
> > } else { > > WARN_ON_ONCE(state != VTIME_GUEST); > > if (task_nice(tsk) > 0) { > > - cpustat[CPUTIME_GUEST_NICE] += vtime->gtime + delta; > > - cpustat[CPUTIME_NICE] += vtime->gtime + delta; > > + cpustat[CPUTIME_GUEST_NICE] += delta; > > + cpustat[CPUTIME_NICE] += delta; > > } else { > > - cpustat[CPUTIME_GUEST] += vtime->gtime + delta; > > - cpustat[CPUTIME_USER] += vtime->gtime + delta; > > + cpustat[CPUTIME_GUEST] += delta; > > + cpustat[CPUTIME_USER] += delta; > > } > > } > > } while (read_seqcount_retry(&vtime->seqcount, seq)); > > .
| |