All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Russell King <linux@arm.linux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] ARM: sched_clock: Load cycle count after epoch stabilizes
Date: Mon, 17 Jun 2013 15:58:28 -0700	[thread overview]
Message-ID: <51BF9494.9000209@linaro.org> (raw)
In-Reply-To: <1371508858-23371-1-git-send-email-sboyd@codeaurora.org>

On 06/17/2013 03:40 PM, Stephen Boyd wrote:
> There is a small race between when the cycle count is read from
> the hardware and when the epoch stabilizes. Consider this
> scenario:
>
>   CPU0                           CPU1
>   ----                           ----
>   cyc = read_sched_clock()
>   cyc_to_sched_clock()
>                                   update_sched_clock()
>                                    ...
>                                    cd.epoch_cyc = cyc;
>    epoch_cyc = cd.epoch_cyc;
>    ...
>    epoch_ns + cyc_to_ns((cyc - epoch_cyc)
>
> The cyc on cpu0 was read before the epoch changed. But we
> calculate the nanoseconds based on the new epoch by subtracting
> the new epoch from the old cycle count. Since epoch is most likely
> larger than the old cycle count we calculate a large number that
> will be converted to nanoseconds and added to epoch_ns, causing
> time to jump forward too much.
>
> Fix this problem by reading the hardware after the epoch has
> stabilized.
>
> Cc: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Thanks for the resend here.

I've got this in my tree and unless I get an objection in the next day 
or so, I'll send it on to Thomas.

thanks
-john

WARNING: multiple messages have this Message-ID (diff)
From: john.stultz@linaro.org (John Stultz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: sched_clock: Load cycle count after epoch stabilizes
Date: Mon, 17 Jun 2013 15:58:28 -0700	[thread overview]
Message-ID: <51BF9494.9000209@linaro.org> (raw)
In-Reply-To: <1371508858-23371-1-git-send-email-sboyd@codeaurora.org>

On 06/17/2013 03:40 PM, Stephen Boyd wrote:
> There is a small race between when the cycle count is read from
> the hardware and when the epoch stabilizes. Consider this
> scenario:
>
>   CPU0                           CPU1
>   ----                           ----
>   cyc = read_sched_clock()
>   cyc_to_sched_clock()
>                                   update_sched_clock()
>                                    ...
>                                    cd.epoch_cyc = cyc;
>    epoch_cyc = cd.epoch_cyc;
>    ...
>    epoch_ns + cyc_to_ns((cyc - epoch_cyc)
>
> The cyc on cpu0 was read before the epoch changed. But we
> calculate the nanoseconds based on the new epoch by subtracting
> the new epoch from the old cycle count. Since epoch is most likely
> larger than the old cycle count we calculate a large number that
> will be converted to nanoseconds and added to epoch_ns, causing
> time to jump forward too much.
>
> Fix this problem by reading the hardware after the epoch has
> stabilized.
>
> Cc: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Thanks for the resend here.

I've got this in my tree and unless I get an objection in the next day 
or so, I'll send it on to Thomas.

thanks
-john

  reply	other threads:[~2013-06-17 22:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17 22:40 [PATCH v2] ARM: sched_clock: Load cycle count after epoch stabilizes Stephen Boyd
2013-06-17 22:40 ` Stephen Boyd
2013-06-17 22:58 ` John Stultz [this message]
2013-06-17 22:58   ` John Stultz

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=51BF9494.9000209@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=sboyd@codeaurora.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.