[RFC v2] ARM: sched_clock: update epoch_cyc on resume
From: Linus Walleij <hidden>
Date: 2012-08-05 00:18:35
Also in:
lkml
On Fri, Aug 3, 2012 at 3:28 AM, Colin Cross [off-list ref] wrote:
On Fri, Jul 27, 2012 at 8:30 PM, Colin Cross [off-list ref] wrote:quoted
On Fri, Jul 27, 2012 at 6:15 PM, Colin Cross [off-list ref] wrote:quoted
That patch was merged in 3.4, and my patch is on top of it. Your patch updates epoch_cyc and epoch_ns in suspend, but if the first call to cyc_to_sched_clock after resume gets cyc = 0, cyc - epoch_cyc can be negative, although it will be cast back to a large positive number. With my patch, epoch_cyc is updated in resume to whatever read_sched_clock() returns, and epoch_ns is still set to the suspend value, so it appears that sched_clock has not changed between sched_clock_suspend and sched_clock_resume. It will work with any timer behavior (reset to 0, reset to random value, or continuing counting). The old setup_sched_clock function maintains the old behavior to appease those who like their 32kHz sched clock to continue ticking in suspend, although I think it is more correct for all sched clocks to be faster than 32 kHz (when possible) and stop in suspend.I think the existing code can cause sched_clock to go backwards if the register read by the read function resets to 0 in suspend: In sched_clock_suspend epoch_cyc is updated to 0x00002000. The first sched_clock call after resume gets cyc = 0, returning epoch_ns + cyc_to_ns(0xffffe000) Later, sched_clock gets cyc = 0x5000, returning epoch_ns + cyc_to_ns(0x3000), which will be much smaller than the previous sched_clock value.Russell, any update on this? Should sched_clock.c handle read functions that go backwards in suspend, or should I modify the read function to track an offset in suspend and always return a monotonically increasing value across suspend?
Colin, I suggest you put this into Russell's patch tracker so he can keep track of it from there. Yours, Linus Walleij