From: Andrew Pinski <apinski@cavium.com>
To: pinskia@gmail.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Andrew Pinski <apinski@cavium.com>
Subject: [PATCH 1/2] ARM64:VDSO: Improve gettimeofday, don't use udiv
Date: Sun, 13 Mar 2016 12:50:19 -0700 [thread overview]
Message-ID: <1457898620-1867-2-git-send-email-apinski@cavium.com> (raw)
In-Reply-To: <1457898620-1867-1-git-send-email-apinski@cavium.com>
On many cores, udiv with a large value is slow, expand instead
the division out to be what GCC would have generated for the
divide by 1000.
On ThunderX, the speeds up gettimeofday by 5%.
Signed-off-by: Andrew Pinski <apinski@cavium.com>
---
arch/arm64/kernel/vdso/gettimeofday.S | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
index efa79e8..e5caef9 100644
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -64,10 +64,22 @@ ENTRY(__kernel_gettimeofday)
bl __do_get_tspec
seqcnt_check w9, 1b
- /* Convert ns to us. */
- mov x13, #1000
- lsl x13, x13, x12
- udiv x11, x11, x13
+ /* Undo the shift. */
+ lsr x11, x11, x12
+
+ /* Convert ns to us (division by 1000 by using multiply high).
+ * This is how GCC converts the division by 1000 into.
+ * This is faster than divide on most cores.
+ */
+ mov x13, 63439
+ movk x13, 0xe353, lsl 16
+ lsr x11, x11, 3
+ movk x13, 0x9ba5, lsl 32
+ movk x13, 0x20c4, lsl 48
+ /* x13 = 0x20c49ba5e353f7cf */
+ umulh x11, x11, x13
+ lsr x11, x11, 4
+
stp x10, x11, [x0, #TVAL_TV_SEC]
2:
/* If tz is NULL, return 0. */
--
1.7.2.5
next prev parent reply other threads:[~2016-03-13 19:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-13 19:50 [PATCH 0/2] *** SUBJECT HERE *** Andrew Pinski
2016-03-13 19:50 ` Andrew Pinski [this message]
2016-03-14 6:55 ` [PATCH 1/2] ARM64:VDSO: Improve gettimeofday, don't use udiv Ard Biesheuvel
2016-03-10 17:00 ` Mark Rutland
2016-03-24 14:36 ` Christopher Covington
2016-03-13 19:50 ` [PATCH 2/2] ARM64:VDSO: Improve __do_get_tspec, " 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=1457898620-1867-2-git-send-email-apinski@cavium.com \
--to=apinski@cavium.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pinskia@gmail.com \
/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
Powered by JetHome