Re: [BUG nohz]: wrong user and system time accounting
From: Rik van Riel
Date: Wed Mar 29 2017 - 16:09:37 EST
On Wed, 2017-03-29 at 13:16 -0400, Luiz Capitulino wrote:
> On Tue, 28 Mar 2017 13:24:06 -0400
> Luiz Capitulino <lcapitulino@xxxxxxxxxx> wrote:
>
> > Â1. In my tracing I'm seeing that sometimes (always?) the
> > ÂÂÂÂtime interval between two timer interrupts is less than 1ms
>
> I think that's the root cause.
>Â
> In this trace, we see the following:
>
> Â1. On CPU15, we transition from user-space to kernel-space because
> ÂÂÂÂof a timer interrupt (it's the tick)
>
> Â2. vtimer_delta() returns 0, because jiffies didn't change since the
> ÂÂÂÂlast accounting
>
> Â3. While CPU15 is executing in kernel-space, jiffies is updated
> ÂÂÂÂby CPU0
>
> Â4. When going back to user-space, vtime_delta() returns non-zero
> ÂÂÂÂand the whole time is accounted for system time (observe how
> ÂÂÂÂthe cputime parameter in account_system_time() is less than 1ms)
In other words, the tick on cpu0 is aligned
with the tick on the nohz_full cpus, and
jiffies is advanced while the nohz_full cpus
with an active tick happen to be in kernel
mode?
Frederic, can you think of any reason why
the tick on nohz_full CPUs would end up aligned
with the tick on cpu0, instead of running at some
random offset?
A random offset, or better yet a somewhat randomized
tick length to make sure that simultaneous ticks are
fairly rare and the vtime sampling does not end up
"in phase" with the jiffies incrementing, could make
the accounting work right again.
Of course, that assumes the above hypothesis is correct :)