powerpc: Add VDSO version of time
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Mon, 22 Apr 2013 09:29:33 +0000 (09:29 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 23 Apr 2013 06:05:05 +0000 (16:05 +1000)
On 04/18/2013 07:38 PM, Anton Blanchard wrote:
> Since you are only reading one long you shouldn't need to check the
> update count and loop, you will always see a consistent value. The
> system call version of time() just does an unprotected load for example.

Fixed.

> With the above change and with Michael's comments covered (decent
> changelog entry and Signed-off-by):
>
> Acked-by: Anton Blanchard <anton@samba.org>

Thanks for the review, below the updated patch:

From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>

This patch implement the time syscall as vDSO. The performance speedups
are:

Baseline PPC32: 380 nsec
Baseline PPC64: 350 nsec
vdso PPC32:      20 nsec
vsdo PPC64:      20 nsec

Tested on 64 bit build with both 32 bit and 64 bit userland.

Acked-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/vdso.c
arch/powerpc/kernel/vdso32/gettimeofday.S
arch/powerpc/kernel/vdso32/vdso32.lds.S
arch/powerpc/kernel/vdso64/gettimeofday.S
arch/powerpc/kernel/vdso64/vdso64.lds.S

index 1b2076f049cecaf954b111df7a6a07b964258c52..d4f463ac65b1ea6d1dd00e3f52925745f7c136e2 100644 (file)
@@ -113,6 +113,10 @@ static struct vdso_patch_def vdso_patches[] = {
                CPU_FTR_USE_TB, 0,
                "__kernel_get_tbfreq", NULL
        },
+       {
+               CPU_FTR_USE_TB, 0,
+               "__kernel_time", NULL
+       },
 };
 
 /*
index 4ee09ee2e836d3994e8069d3117f6bc188c492a6..27e2f623210b73b04bf987b02a3b7b9d2cd0f73b 100644 (file)
@@ -180,6 +180,32 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
 V_FUNCTION_END(__kernel_clock_getres)
 
 
+/*
+ * Exact prototype of time()
+ *
+ * time_t time(time *t);
+ *
+ */
+V_FUNCTION_BEGIN(__kernel_time)
+  .cfi_startproc
+       mflr    r12
+  .cfi_register lr,r12
+
+       mr      r11,r3                  /* r11 holds t */
+       bl      __get_datapage@local
+       mr      r9, r3                  /* datapage ptr in r9 */
+
+       lwz     r3,STAMP_XTIME+TSPEC_TV_SEC(r9)
+
+       cmplwi  r11,0                   /* check if t is NULL */
+       beq     2f
+       stw     r3,0(r11)               /* store result at *t */
+2:     mtlr    r12
+       crclr   cr0*4+so
+       blr
+  .cfi_endproc
+V_FUNCTION_END(__kernel_time)
+
 /*
  * This is the core of clock_gettime() and gettimeofday(),
  * it returns the current time in r3 (seconds) and r4.
index 43200ba2e57004f74e3f990d427d729c789e07c9..f223409629b9c768891f54a4f117ed964a25a0e2 100644 (file)
@@ -150,6 +150,7 @@ VERSION
 #ifdef CONFIG_PPC64
                __kernel_getcpu;
 #endif
+               __kernel_time;
 
        local: *;
        };
index e97a9a0dc4ac3af3545118d6dbc190d515be4e0f..a76b4af37ef297cdac6688785ed65d55d673bc66 100644 (file)
@@ -164,6 +164,32 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
   .cfi_endproc
 V_FUNCTION_END(__kernel_clock_getres)
 
+/*
+ * Exact prototype of time()
+ *
+ * time_t time(time *t);
+ *
+ */
+V_FUNCTION_BEGIN(__kernel_time)
+  .cfi_startproc
+       mflr    r12
+  .cfi_register lr,r12
+
+       mr      r11,r3                  /* r11 holds t */
+       bl      V_LOCAL_FUNC(__get_datapage)
+
+       ld      r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
+
+       cmpldi  r11,0                   /* check if t is NULL */
+       beq     2f
+       std     r4,0(r11)               /* store result at *t */
+2:     mtlr    r12
+       crclr   cr0*4+so
+       mr      r3,r4
+       blr
+  .cfi_endproc
+V_FUNCTION_END(__kernel_time)
+
 
 /*
  * This is the core of clock_gettime() and gettimeofday(),
index e6c1758f3588c4c2d4e5f314e489a8c4c8b65a36..e4863819663b35d0ca8658a5f1fd374c4b0da5c7 100644 (file)
@@ -147,6 +147,7 @@ VERSION
                __kernel_sync_dicache_p5;
                __kernel_sigtramp_rt64;
                __kernel_getcpu;
+               __kernel_time;
 
        local: *;
        };