]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
s390/idle: Provide arch specific kcpustat_field_idle()/kcpustat_field_iowait()
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 13 May 2026 14:01:28 +0000 (16:01 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Mon, 15 Jun 2026 14:33:40 +0000 (16:33 +0200)
commit670e057744e0cc8047bf96d15d18c46e16ae2e93
tree9cf364ebd26c84e9208ecc8f5febe224d71645b8
parent4fe307f0f5c1fa6afff9175f59930dcd39ee99fd
s390/idle: Provide arch specific kcpustat_field_idle()/kcpustat_field_iowait()

The former s390 specific arch_cpu_idle_time() implementation was
removed, since its implementation was racy and reported idle time
could go backwards [1].

However this removal was not necessary, since independently of the s390
architecture specific races there exists the iowait counter update race,
which can also lead to reported idle time going backwards [2].

With Frederic Weisbecker's recent cpu idle time accounting refactoring
kernel_cpustat got a sequence counter. Use this to implement s390 specific
variants of kcpustat_field_idle() and kcpustat_field_iowait(). This is
logically a revert of [1] and moves cpu idle time accounting back into s390
architecture code, which is also more precise than the dyntick idle time
accounting by nohz/scheduler.

For comparing cross cpu time stamps it is necessary to use the stcke
instead of the stckf instruction in irq entry path. Furthermore this
open-codes a sequence lock in assembler and C code, which is required to
update the irq entry time stamp to the per cpu idle_data structure in a
race free manner.

[1] commit be76ea614460 ("s390/idle: remove arch_cpu_idle_time() and corresponding code")
[2] commit ead70b752373 ("timers/nohz: Add a comment about broken iowait counter update race")

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/idle.h
arch/s390/kernel/asm-offsets.c
arch/s390/kernel/entry.S
arch/s390/kernel/idle.c
arch/s390/kernel/vtime.c
include/linux/kernel_stat.h
include/linux/vtime.h
kernel/sched/cputime.c