On 08/18/2013 08:04 PM, Oleg Nesterov wrote: > Sorry for double post. forgot to cc cpufreq maintainers. > > On 08/16, Frederic Weisbecker wrote: >> >> To fix this, lets only update the sleeptime stats locally when the CPU >> exits from idle. > > I am in no position to ack the changes in this area, but I like this > change very much. Because, as a code reader, I was totally confused by > > if (last_update_time) > update_ts_time_stats() > > code and it looks "obviously wrong". > > I added more cc's. It seems to me that 9366d840 "cpufreq: governors: > Calculate iowait time only when necessary" doesn't realize what > > - u64 idle_time = get_cpu_idle_time_us(cpu, NULL); > + u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : > NULL); > > actually means. OTOH, get_cpu_iowait_time_us() was called with > last_update_time != NULL even before this patch...
To be honest, I am unfamiliar with tick-sched code. With patch 9366d840, I was trying to avoid duplicate calls to get_cpu_iowait_time_us function. I just saw that the original code was calling update_ts_time_stats within get_cpu_idle_time_us and get_cpu_iowait_time_us and I thought that I should keep calling these functions with non NULL parameter to update the time stats. In fact the original patch submission was without this: - u64 idle_time = get_cpu_idle_time_us(cpu, NULL); + u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); and the idle time calculation was wrong (ondemand couldn't increase to max freq) For your convenience the call paths before and after this patch: Before patch get_cpu_idle_time(j, &cur_wall_time); u64 idle_time = get_cpu_idle_time_us(cpu, NULL); idle_time += get_cpu_iowait_time_us(cpu, wall); update_ts_time_stats(cpu, ts, now, last_update_time); ... get_cpu_iowait_time_us(j, &cur_wall_time); update_ts_time_stats(cpu, ts, now, last_update_time); After patch (io_busy = 1) cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy); u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); update_ts_time_stats(cpu, ts, now, last_update_time); After patch (io_busy = 0) cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy); u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); idle_time += get_cpu_iowait_time_us(cpu, wall); update_ts_time_stats(cpu, ts, now, last_update_time); Regards, Stratos -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/