sched/cputime: Handle dyntick-idle steal time correctly
authorFrederic Weisbecker <frederic@kernel.org>
Fri, 8 May 2026 13:16:47 +0000 (15:16 +0200)
committerThomas Gleixner <tglx@kernel.org>
Tue, 2 Jun 2026 19:27:26 +0000 (21:27 +0200)
commit6199f9999a9b62b2b84a1bf5b52a9fd0bb8de5af
tree94f89d7634ee9a95d4fd196becc23a9946ae900c
parent7198e3927a14535475a24cce559f41f97e6c0b66
sched/cputime: Handle dyntick-idle steal time correctly

The dyntick-idle steal time is currently accounted when the tick restarts
but the stolen idle time is not subtracted from the idle time that was
already accounted. This is to avoid observing the idle time going backward
as the dyntick-idle cputime accessors can't reliably know in advance the
stolen idle time.

In order to maintain a forward progressing idle cputime while subtracting
idle steal time from it, keep track of the previously accounted idle stolen
time and substract it from _later_ idle cputime accounting.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Link: https://patch.msgid.link/20260508131647.43868-16-frederic@kernel.org
include/linux/kernel_stat.h
kernel/sched/cputime.c