[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51BF9494.9000209@linaro.org>
Date: Mon, 17 Jun 2013 15:58:28 -0700
From: John Stultz <john.stultz@...aro.org>
To: Stephen Boyd <sboyd@...eaurora.org>
CC: linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Russell King <linux@....linux.org.uk>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH v2] ARM: sched_clock: Load cycle count after epoch stabilizes
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@....linux.org.uk>
> Signed-off-by: Stephen Boyd <sboyd@...eaurora.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists