linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2] ARM: sched_clock: update epoch_cyc on resume
Date: Thu, 2 Aug 2012 18:28:47 -0700	[thread overview]
Message-ID: <CAMbhsRSboLABOD8eX4czk8FsG3QmT60RTr+znVCqwWR6ZGhgaw@mail.gmail.com> (raw)
In-Reply-To: <CAMbhsRQg4pETrM7cx+aSBzGn3S1LV_x7vo8X3A300vCWTjkFng@mail.gmail.com>

On Fri, Jul 27, 2012 at 8:30 PM, Colin Cross <ccross@android.com> wrote:
> On Fri, Jul 27, 2012 at 6:15 PM, Colin Cross <ccross@android.com> wrote:
>> 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?

  reply	other threads:[~2012-08-03  1:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25  2:49 [RFC v2] ARM: sched_clock: update epoch_cyc on resume Colin Cross
2012-07-27 23:32 ` Linus Walleij
2012-07-27 23:38   ` Russell King - ARM Linux
2012-07-28  1:15     ` Colin Cross
2012-07-28  3:30       ` Colin Cross
2012-08-03  1:28         ` Colin Cross [this message]
2012-08-05  0:18           ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMbhsRSboLABOD8eX4czk8FsG3QmT60RTr+znVCqwWR6ZGhgaw@mail.gmail.com \
    --to=ccross@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).