]> xenbits.xensource.com Git - people/julieng/linux-arm.git/commitdiff
ARM64:VDSO: Improve gettimeofday, don't use udiv
authorAndrew Pinski <apinski@cavium.com>
Thu, 5 Mar 2015 07:50:49 +0000 (23:50 -0800)
committerJulien Grall <julien.grall@citrix.com>
Mon, 28 Sep 2015 11:05:16 +0000 (12:05 +0100)
On some 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.

Signed-off-by: Andrew Pinski <apinski@cavium.com>
Signed-off-by: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
arch/arm64/kernel/vdso/gettimeofday.S

index efa79e8d4196d01318779cd76f2e926c40765ae9..e5caef9e0ec810dce34bd404727f040e55c6f3ae 100644 (file)
@@ -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. */