On Thu, 2011-12-15 at 14:06 +0100, Linus Walleij wrote:
On Thu, Dec 15, 2011 at 1:16 PM, Daniel Lezcano daniel.lezcano@linaro.org wrote:
[Me]
It is easy to reproduce with 'time sleep 1' where the timer expires 1, 2 or 3 seconds later.
It seems that does not happen with linux-linaro-3.1 but I was able to reproduce the problem on a vanilla kernel 3.1.5.
Is it a known problem ?
Sleeps are only guaranteed at max speed.
I am not sure to get the point. Do you mean cpufreq max frequency ?
It means that the kernel idea of sleep(1) is, sleep atleast 1 second, possibly more. When the system scales down frequency, say to half the frequency, things start to take twice the time. So sleep(1) may result in 2 seconds of sleep or so.
Just a minor clarification: So, while Linus is right that sleep can validly go longer then the requested time (the only promise is that it shouldn't return success early), sleep() should be timer based (not delay based), so even if the frequency drops, you *shouldn't* see freq proportional delays.
If that were happening, it would seem timekeeping would also be slowed down, which def shouldn't happen if we're using a sane clocksource (although broken clocksources - which may change freq with the cpu - have caused symptoms like the above).
That said, Linus knows more about the specific issues around the board, so I'd defer to him in debugging the issue. I just didn't want anyone to get the impression that sleep length *should* be proportional to cpu freq.
thanks -john