The idle and iowait statistics in /proc/stat are obtained through
get_idle_time and get_iowait_time. Assuming CONFIG_NO_HZ_COMMON is
enabled, when CPU is online, the idle and iowait values use the
idle_sleeptime and iowait_sleeptime statistics from tick_cpu_sched, but
use CPUTIME_IDLE and CPUTIME_IOWAIT items from kernel_cpustat when CPU
is offline. It will cause idle/iowait fluctuation in the aggregated
statistics print by /proc/stat.
Introduce get_cpu_idle_time_us_raw and get_cpu_iowait_time_us_raw, so that
/proc/stat logic can use them to get the last raw value of idle_sleeptime
and iowait_sleeptime from tick_cpu_sched without any calculation when CPU
is offline. It avoids /proc/stat idle/iowait fluctuation when cpu hotplug.
In addition, revise a comment about broken iowait counter update race
related to the topic.
Xin Zhao (2):
timers/nohz: Revise a comment about broken iowait counter update race
timers/nohz: Avoid /proc/stat idle/iowait fluctuation when cpu hotplug
fs/proc/stat.c | 4 ++++
include/linux/tick.h | 4 ++++
kernel/time/tick-sched.c | 50 ++++++++++++++++++++++++++++++++++++++--
3 files changed, 56 insertions(+), 2 deletions(-)
--
2.34.1