From: Andrew Pinski <apinski@cavium.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Andrew Pinski <apinski@cavium.com>
Subject: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday.
Date: Tue, 30 May 2017 17:34:20 -0700 [thread overview]
Message-ID: <1496190860-5116-2-git-send-email-apinski@cavium.com> (raw)
In-Reply-To: <1496190860-5116-1-git-send-email-apinski@cavium.com>
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>
---
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 1293786..49edd35 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 &= ~(0xff00ull<<48);
return res * mult;
--
2.7.4
next prev parent reply other threads:[~2017-05-31 0:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 0:34 [PATCHv2 1/2] arm64:vdso: Rewrite gettimeofday into C Andrew Pinski
2017-05-31 0:34 ` Andrew Pinski [this message]
2017-05-31 12:44 ` Will Deacon
2017-05-31 13:59 ` Yury Norov
2017-06-01 6:10 ` Pinski, Andrew
2017-06-01 15:25 ` Nathan Lynch
2017-08-01 9:30 ` Robert Richter
2017-08-01 17:00 ` Will Deacon
-- strict thread matches above, loose matches on Subject: below --
2017-04-23 23:47 [PATCH " 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
[not found] ` <CY4PR07MB3415D0B108BE622CF94B205893E80@CY4PR07MB3415.namprd07.prod.outlook.com>
2017-05-06 17:38 ` Pinski, Andrew
2017-05-06 19:34 ` Jon Masters
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=1496190860-5116-2-git-send-email-apinski@cavium.com \
--to=apinski@cavium.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.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