diff options
author | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2013-04-22 05:29:33 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-04-23 02:05:05 -0400 |
commit | fcb41a2030abe0eb716ef0798035ef9562097f42 (patch) | |
tree | 4b063cc1cb872fb9609fd90485c7b602b9fdc57f /arch/powerpc | |
parent | af81d7878c641629f2693ae3fdaf74b4af14dfca (diff) |
powerpc: Add VDSO version of time
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>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/vdso.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/vdso32/gettimeofday.S | 26 | ||||
-rw-r--r-- | arch/powerpc/kernel/vdso32/vdso32.lds.S | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/vdso64/gettimeofday.S | 26 | ||||
-rw-r--r-- | arch/powerpc/kernel/vdso64/vdso64.lds.S | 1 |
5 files changed, 58 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index 1b2076f049ce..d4f463ac65b1 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c | |||
@@ -113,6 +113,10 @@ static struct vdso_patch_def vdso_patches[] = { | |||
113 | CPU_FTR_USE_TB, 0, | 113 | CPU_FTR_USE_TB, 0, |
114 | "__kernel_get_tbfreq", NULL | 114 | "__kernel_get_tbfreq", NULL |
115 | }, | 115 | }, |
116 | { | ||
117 | CPU_FTR_USE_TB, 0, | ||
118 | "__kernel_time", NULL | ||
119 | }, | ||
116 | }; | 120 | }; |
117 | 121 | ||
118 | /* | 122 | /* |
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index 4ee09ee2e836..27e2f623210b 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S | |||
@@ -181,6 +181,32 @@ V_FUNCTION_END(__kernel_clock_getres) | |||
181 | 181 | ||
182 | 182 | ||
183 | /* | 183 | /* |
184 | * Exact prototype of time() | ||
185 | * | ||
186 | * time_t time(time *t); | ||
187 | * | ||
188 | */ | ||
189 | V_FUNCTION_BEGIN(__kernel_time) | ||
190 | .cfi_startproc | ||
191 | mflr r12 | ||
192 | .cfi_register lr,r12 | ||
193 | |||
194 | mr r11,r3 /* r11 holds t */ | ||
195 | bl __get_datapage@local | ||
196 | mr r9, r3 /* datapage ptr in r9 */ | ||
197 | |||
198 | lwz r3,STAMP_XTIME+TSPEC_TV_SEC(r9) | ||
199 | |||
200 | cmplwi r11,0 /* check if t is NULL */ | ||
201 | beq 2f | ||
202 | stw r3,0(r11) /* store result at *t */ | ||
203 | 2: mtlr r12 | ||
204 | crclr cr0*4+so | ||
205 | blr | ||
206 | .cfi_endproc | ||
207 | V_FUNCTION_END(__kernel_time) | ||
208 | |||
209 | /* | ||
184 | * This is the core of clock_gettime() and gettimeofday(), | 210 | * This is the core of clock_gettime() and gettimeofday(), |
185 | * it returns the current time in r3 (seconds) and r4. | 211 | * it returns the current time in r3 (seconds) and r4. |
186 | * On entry, r7 gives the resolution of r4, either USEC_PER_SEC | 212 | * On entry, r7 gives the resolution of r4, either USEC_PER_SEC |
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S index 43200ba2e570..f223409629b9 100644 --- a/arch/powerpc/kernel/vdso32/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S | |||
@@ -150,6 +150,7 @@ VERSION | |||
150 | #ifdef CONFIG_PPC64 | 150 | #ifdef CONFIG_PPC64 |
151 | __kernel_getcpu; | 151 | __kernel_getcpu; |
152 | #endif | 152 | #endif |
153 | __kernel_time; | ||
153 | 154 | ||
154 | local: *; | 155 | local: *; |
155 | }; | 156 | }; |
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S index e97a9a0dc4ac..a76b4af37ef2 100644 --- a/arch/powerpc/kernel/vdso64/gettimeofday.S +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S | |||
@@ -164,6 +164,32 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) | |||
164 | .cfi_endproc | 164 | .cfi_endproc |
165 | V_FUNCTION_END(__kernel_clock_getres) | 165 | V_FUNCTION_END(__kernel_clock_getres) |
166 | 166 | ||
167 | /* | ||
168 | * Exact prototype of time() | ||
169 | * | ||
170 | * time_t time(time *t); | ||
171 | * | ||
172 | */ | ||
173 | V_FUNCTION_BEGIN(__kernel_time) | ||
174 | .cfi_startproc | ||
175 | mflr r12 | ||
176 | .cfi_register lr,r12 | ||
177 | |||
178 | mr r11,r3 /* r11 holds t */ | ||
179 | bl V_LOCAL_FUNC(__get_datapage) | ||
180 | |||
181 | ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3) | ||
182 | |||
183 | cmpldi r11,0 /* check if t is NULL */ | ||
184 | beq 2f | ||
185 | std r4,0(r11) /* store result at *t */ | ||
186 | 2: mtlr r12 | ||
187 | crclr cr0*4+so | ||
188 | mr r3,r4 | ||
189 | blr | ||
190 | .cfi_endproc | ||
191 | V_FUNCTION_END(__kernel_time) | ||
192 | |||
167 | 193 | ||
168 | /* | 194 | /* |
169 | * This is the core of clock_gettime() and gettimeofday(), | 195 | * This is the core of clock_gettime() and gettimeofday(), |
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S index e6c1758f3588..e4863819663b 100644 --- a/arch/powerpc/kernel/vdso64/vdso64.lds.S +++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S | |||
@@ -147,6 +147,7 @@ VERSION | |||
147 | __kernel_sync_dicache_p5; | 147 | __kernel_sync_dicache_p5; |
148 | __kernel_sigtramp_rt64; | 148 | __kernel_sigtramp_rt64; |
149 | __kernel_getcpu; | 149 | __kernel_getcpu; |
150 | __kernel_time; | ||
150 | 151 | ||
151 | local: *; | 152 | local: *; |
152 | }; | 153 | }; |