nohz: stat: Fix CPU iowait time accounting
Bo Yan [Tue, 2 Apr 2013 17:44:52 +0000 (10:44 -0700)]
Since cpustat[CPUTIME_IOWAIT] is never connected to
ts->iowait_sleeptime, never read from cpustat[CPUTIME_IOWAIT] when
reporting stats in /proc/stat.

Note this was rejected by Michal Hocko when it was initially proposed
by Martin Schwidefsky in LKML, so if you want to upstream it, better
find an alternative (either completely disable cpustat[CPUTIME_IOWAIT]
for CONFIG_NO_HZ or somehow connect them to keep them in sync.)

bug 1190321

Change-Id: Iee057315f871a5b99e3647494d3e4095e0c9680f
Signed-off-by: Bo Yan <byan@nvidia.com>
Reviewed-on: http://git-master/r/215620
Reviewed-by: Liang Cheng (SW) <licheng@nvidia.com>
Tested-by: Liang Cheng (SW) <licheng@nvidia.com>

fs/proc/stat.c

index ffcda1f..734ecec 100644 (file)
@@ -62,11 +62,10 @@ static u64 get_iowait_time(int cpu)
 {
        u64 iowait, iowait_time = -1ULL;
 
-       if (cpu_online(cpu))
-               iowait_time = get_cpu_iowait_time_us(cpu, NULL);
+       iowait_time = get_cpu_iowait_time_us(cpu, NULL);
 
        if (iowait_time == -1ULL)
-               /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
+               /* !NO_HZ so we can rely on cpustat.iowait */
                iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
        else
                iowait = usecs_to_cputime64(iowait_time);