Re: [RFC] cputime: Introduce option to force full dynticks accounting on NOHZ & NOHZ_IDLE CPUs

From: Nicolas Saenz Julienne
Date: Mon Mar 11 2024 - 13:15:53 EST


Hi Frederic,

On Mon Feb 19, 2024 at 5:57 PM UTC, Nicolas Saenz Julienne wrote:
> Under certain extreme conditions, the tick-based cputime accounting may
> produce inaccurate data. For instance, guest CPU usage is sensitive to
> interrupts firing right before the tick's expiration. This forces the
> guest into kernel context, and has that time slice wrongly accounted as
> system time. This issue is exacerbated if the interrupt source is in
> sync with the tick, significantly skewing usage metrics towards system
> time.
>
> On CPUs with full dynticks enabled, cputime accounting leverages the
> context tracking subsystem to measure usage, and isn't susceptible to
> this sort of race conditions. However, this imposes a bigger overhead,
> including additional accounting and the extra dyntick tracking during
> user<->kernel<->guest transitions (RmW + mb).
>
> So, in order to get the best of both worlds, introduce a cputime
> configuration option that allows using the full dynticks accounting
> scheme on NOHZ & NOHZ_IDLE CPUs, while avoiding the expensive
> user<->kernel<->guest dyntick transitions.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenz@xxxxxxxxxx>
> Signed-off-by: Jack Allister <jalliste@xxxxxxxxxxxx>
> ---

Would you be opposed to introducing a config option like this? Any
alternatives you might have in mind?

Nicolas