lkml.org 
[lkml]   [2022]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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));
> > .

\
 
 \ /
  Last update: 2022-09-30 14:17    [W:0.060 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site