From: jcm@jonmasters.org (Jon Masters)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday.
Date: Sat, 6 May 2017 12:29:03 -0400 [thread overview]
Message-ID: <7ac07a75-ec3b-d05e-061c-5efab751ae2b@jonmasters.org> (raw)
In-Reply-To: <1492991221-5156-2-git-send-email-apinski@cavium.com>
On 04/23/2017 07:47 PM, Andrew Pinski wrote:
> ISB is normally required before mrs CNTVCT if we want the
> mrs to completed after the loads. In this case it is not.
> As we are taking the difference and if that difference
> was going to be negative, we just use the last counter value
> instead.
>
> Signed-off-by: Andrew Pinski <apinski@cavium.com>
Humor me. Walk me through this?
> ---
> arch/arm64/kernel/vdso/gettimeofday.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/vdso/gettimeofday.c b/arch/arm64/kernel/vdso/gettimeofday.c
> index a0ab8b1..cf3235a 100644
> --- a/arch/arm64/kernel/vdso/gettimeofday.c
> +++ b/arch/arm64/kernel/vdso/gettimeofday.c
> @@ -117,10 +117,20 @@ static notrace u64 get_clock_shifted_nsec(u64 cycle_last, u64 mult)
> u64 res;
>
> /* Read the virtual counter. */
> - isb();
> + /*
> + * This normally requires an ISB but since we know the
> + * read of the last cycle will always be after the
> + * read of the values are valid word.
> + */
> asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
>
> - res = res - cycle_last;
> + /*
> + * If the current cycle is greater than the last,
> + * then get the difference.
> + */
> + if (res > cycle_last)
> + res = res - cycle_last;
> +
> /* We can only guarantee 56 bits of precision. */
> res &= ~(0xff00ul<<48);
> return res * mult;
>
--
Computer Architect
next prev parent reply other threads:[~2017-05-06 16:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-23 23:47 [PATCH 1/2] arm64:vdso: Rewrite gettimeofday into C Andrew Pinski
2017-04-23 23:47 ` [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday Andrew Pinski
2017-05-06 16:29 ` Jon Masters [this message]
[not found] ` <CY4PR07MB3415D0B108BE622CF94B205893E80@CY4PR07MB3415.namprd07.prod.outlook.com>
2017-05-06 17:38 ` Pinski, Andrew
2017-05-06 19:34 ` Jon Masters
2017-04-24 15:21 ` [PATCH 1/2] arm64:vdso: Rewrite gettimeofday into C Catalin Marinas
2017-04-24 18:49 ` Andrew Pinski
-- strict thread matches above, loose matches on Subject: below --
2017-05-31 0:34 [PATCHv2 " Andrew Pinski
2017-05-31 0:34 ` [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday Andrew Pinski
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=7ac07a75-ec3b-d05e-061c-5efab751ae2b@jonmasters.org \
--to=jcm@jonmasters.org \
--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