* [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch
@ 2017-09-18 9:23 Santosh Sivaraj
2017-09-18 9:23 ` [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
2017-10-06 9:03 ` [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Naveen N. Rao
0 siblings, 2 replies; 15+ messages in thread
From: Santosh Sivaraj @ 2017-09-18 9:23 UTC (permalink / raw)
To: linuxppc-dev, Naveen N. Rao
Cc: Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju
Reorganize code to make it easy to introduce CLOCK_REALTIME_COARSE and
CLOCK_MONOTONIC_COARSE timer support.
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
arch/powerpc/kernel/vdso64/gettimeofday.S | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 382021324883..a0b4943811db 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -60,18 +60,20 @@ V_FUNCTION_END(__kernel_gettimeofday)
*/
V_FUNCTION_BEGIN(__kernel_clock_gettime)
.cfi_startproc
+ mr r11,r4 /* r11 saves tp */
+ mflr r12 /* r12 saves lr */
+ lis r7,NSEC_PER_SEC@h /* want nanoseconds */
+ ori r7,r7,NSEC_PER_SEC@l
+
/* Check for supported clock IDs */
cmpwi cr0,r3,CLOCK_REALTIME
cmpwi cr1,r3,CLOCK_MONOTONIC
cror cr0*4+eq,cr0*4+eq,cr1*4+eq
- bne cr0,99f
+ beq cr0,49f
- mflr r12 /* r12 saves lr */
+ b 99f /* Fallback to syscall */
.cfi_register lr,r12
- mr r11,r4 /* r11 saves tp */
- bl V_LOCAL_FUNC(__get_datapage) /* get data page */
- lis r7,NSEC_PER_SEC@h /* want nanoseconds */
- ori r7,r7,NSEC_PER_SEC@l
+49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
bne cr1,80f /* if not monotonic, all done */
--
2.13.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-09-18 9:23 [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Santosh Sivaraj
@ 2017-09-18 9:23 ` Santosh Sivaraj
2017-10-06 9:28 ` Naveen N. Rao
2017-10-06 11:25 ` Naveen N. Rao
2017-10-06 9:03 ` [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Naveen N. Rao
1 sibling, 2 replies; 15+ messages in thread
From: Santosh Sivaraj @ 2017-09-18 9:23 UTC (permalink / raw)
To: linuxppc-dev, Naveen N. Rao
Cc: Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
Current vDSO64 implementation does not have support for coarse clocks
(CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
to system call, increasing the response time, vDSO implementation reduces
the cycle time. Below is a benchmark of the difference in execution time
with and without vDSO support.
(Non-coarse clocks are also included just for completion)
Without vDSO support:
--------------------
clock-gettime-realtime: syscall: 172 nsec/call
clock-gettime-realtime: libc: 26 nsec/call
clock-gettime-realtime: vdso: 21 nsec/call
clock-gettime-monotonic: syscall: 170 nsec/call
clock-gettime-monotonic: libc: 30 nsec/call
clock-gettime-monotonic: vdso: 24 nsec/call
clock-gettime-realtime-coarse: syscall: 153 nsec/call
clock-gettime-realtime-coarse: libc: 15 nsec/call
clock-gettime-realtime-coarse: vdso: 9 nsec/call
clock-gettime-monotonic-coarse: syscall: 167 nsec/call
clock-gettime-monotonic-coarse: libc: 15 nsec/call
clock-gettime-monotonic-coarse: vdso: 11 nsec/call
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
arch/powerpc/kernel/asm-offsets.c | 2 ++
arch/powerpc/kernel/vdso64/gettimeofday.S | 56 +++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 8cfb20e38cfe..b55c68c54dc1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -396,6 +396,8 @@ int main(void)
/* Other bits used by the vdso */
DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
+ DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
+ DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index a0b4943811db..bae197a81add 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -71,6 +71,11 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
cror cr0*4+eq,cr0*4+eq,cr1*4+eq
beq cr0,49f
+ cmpwi cr0,r3,CLOCK_REALTIME_COARSE
+ cmpwi cr1,r3,CLOCK_MONOTONIC_COARSE
+ cror cr0*4+eq,cr0*4+eq,cr1*4+eq
+ beq cr0,65f
+
b 99f /* Fallback to syscall */
.cfi_register lr,r12
49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
@@ -112,6 +117,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
1: bge cr1,80f
addi r4,r4,-1
add r5,r5,r7
+ b 80f
+
+ /*
+ * For coarse clocks we get data directly from the vdso data page, so
+ * we don't need to call __do_get_tspec, but we still need to do the
+ * counter trick.
+ */
+65: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
+70: ld r8,CFG_TB_UPDATE_COUNT(r3)
+ andi. r0,r8,1 /* pending update ? loop */
+ bne- 70b
+ xor r0,r8,r8 /* create dependency */
+ add r3,r3,r0
+
+ /*
+ * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
+ * too
+ */
+ ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
+ ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
+ bne cr1,78f
+
+ /* CLOCK_MONOTONIC_COARSE */
+ lwa r6,WTOM_CLOCK_SEC(r3)
+ lwa r9,WTOM_CLOCK_NSEC(r3)
+
+ /* check if counter has updated */
+78: or r0,r6,r9
+ xor r0,r0,r0
+ add r3,r3,r0
+ ld r0,CFG_TB_UPDATE_COUNT(r3)
+ cmpld cr0,r0,r8 /* check if updated */
+ bne- 70b
+
+ /* Counter has not updated, so continue calculating proper values for
+ * sec and nsec if monotonic coarse, or just return with the proper
+ * values for realtime.
+ */
+ bne cr1,80f
+
+ /* Add wall->monotonic offset and check for overflow or underflow */
+ add r4,r4,r6
+ add r5,r5,r9
+ cmpd cr0,r5,r7
+ cmpdi cr1,r5,0
+ blt 79f
+ subf r5,r7,r5
+ addi r4,r4,1
+79: bge cr1,80f
+ addi r4,r4,-1
+ add r5,r5,r7
80: std r4,TSPC64_TV_SEC(r11)
std r5,TSPC64_TV_NSEC(r11)
--
2.13.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch
2017-09-18 9:23 [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Santosh Sivaraj
2017-09-18 9:23 ` [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
@ 2017-10-06 9:03 ` Naveen N. Rao
2017-10-06 10:13 ` Michael Ellerman
1 sibling, 1 reply; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-06 9:03 UTC (permalink / raw)
To: Santosh Sivaraj
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju
Hi Santosh,
On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
> Reorganize code to make it easy to introduce CLOCK_REALTIME_COARSE and
> CLOCK_MONOTONIC_COARSE timer support.
>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/kernel/vdso64/gettimeofday.S | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> index 382021324883..a0b4943811db 100644
> --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> @@ -60,18 +60,20 @@ V_FUNCTION_END(__kernel_gettimeofday)
> */
> V_FUNCTION_BEGIN(__kernel_clock_gettime)
> .cfi_startproc
> + mr r11,r4 /* r11 saves tp */
> + mflr r12 /* r12 saves lr */
> + lis r7,NSEC_PER_SEC@h /* want nanoseconds */
> + ori r7,r7,NSEC_PER_SEC@l
> +
> /* Check for supported clock IDs */
> cmpwi cr0,r3,CLOCK_REALTIME
> cmpwi cr1,r3,CLOCK_MONOTONIC
> cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> - bne cr0,99f
> + beq cr0,49f
>
> - mflr r12 /* r12 saves lr */
> + b 99f /* Fallback to syscall */
'beq', followed by a 'b' looks weird without considering the next patch.
I think this can be organized better to not have to update r7/r11/r12 if
using the system call. See next patch for my comments.
> .cfi_register lr,r12
If you move the mflr, you should move the above line along with it.
- Naveen
> - mr r11,r4 /* r11 saves tp */
> - bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> - lis r7,NSEC_PER_SEC@h /* want nanoseconds */
> - ori r7,r7,NSEC_PER_SEC@l
> +49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> 50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
> bne cr1,80f /* if not monotonic, all done */
>
> --
> 2.13.5
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-09-18 9:23 ` [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
@ 2017-10-06 9:28 ` Naveen N. Rao
2017-10-09 6:27 ` Santosh Sivaraj
2017-10-06 11:25 ` Naveen N. Rao
1 sibling, 1 reply; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-06 9:28 UTC (permalink / raw)
To: Santosh Sivaraj
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
> Current vDSO64 implementation does not have support for coarse clocks
> (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> to system call, increasing the response time, vDSO implementation reduces
> the cycle time. Below is a benchmark of the difference in execution time
> with and without vDSO support.
>
> (Non-coarse clocks are also included just for completion)
>
> Without vDSO support:
> --------------------
> clock-gettime-realtime: syscall: 172 nsec/call
> clock-gettime-realtime: libc: 26 nsec/call
> clock-gettime-realtime: vdso: 21 nsec/call
> clock-gettime-monotonic: syscall: 170 nsec/call
> clock-gettime-monotonic: libc: 30 nsec/call
> clock-gettime-monotonic: vdso: 24 nsec/call
> clock-gettime-realtime-coarse: syscall: 153 nsec/call
> clock-gettime-realtime-coarse: libc: 15 nsec/call
> clock-gettime-realtime-coarse: vdso: 9 nsec/call
> clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> clock-gettime-monotonic-coarse: libc: 15 nsec/call
> clock-gettime-monotonic-coarse: vdso: 11 nsec/call
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/kernel/asm-offsets.c | 2 ++
> arch/powerpc/kernel/vdso64/gettimeofday.S | 56 +++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+)
>
> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> index 8cfb20e38cfe..b55c68c54dc1 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -396,6 +396,8 @@ int main(void)
> /* Other bits used by the vdso */
> DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
>
> diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> index a0b4943811db..bae197a81add 100644
> --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> @@ -71,6 +71,11 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> beq cr0,49f
>
> + cmpwi cr0,r3,CLOCK_REALTIME_COARSE
> + cmpwi cr1,r3,CLOCK_MONOTONIC_COARSE
> + cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> + beq cr0,65f
If you use cr5-7 here, you should be able to re-organize this to not
have to update r4/r11/r12 if we're taking the syscall path. Not
necessarily a huge win by itself, but can also help reuse some of the
other code between the _COARSE and the regular variants.
- Naveen
> +
> b 99f /* Fallback to syscall */
> .cfi_register lr,r12
> 49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> @@ -112,6 +117,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> 1: bge cr1,80f
> addi r4,r4,-1
> add r5,r5,r7
> + b 80f
> +
> + /*
> + * For coarse clocks we get data directly from the vdso data page, so
> + * we don't need to call __do_get_tspec, but we still need to do the
> + * counter trick.
> + */
> +65: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> + andi. r0,r8,1 /* pending update ? loop */
> + bne- 70b
> + xor r0,r8,r8 /* create dependency */
> + add r3,r3,r0
> +
> + /*
> + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> + * too
> + */
> + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> + bne cr1,78f
> +
> + /* CLOCK_MONOTONIC_COARSE */
> + lwa r6,WTOM_CLOCK_SEC(r3)
> + lwa r9,WTOM_CLOCK_NSEC(r3)
> +
> + /* check if counter has updated */
> +78: or r0,r6,r9
> + xor r0,r0,r0
> + add r3,r3,r0
> + ld r0,CFG_TB_UPDATE_COUNT(r3)
> + cmpld cr0,r0,r8 /* check if updated */
> + bne- 70b
> +
> + /* Counter has not updated, so continue calculating proper values for
> + * sec and nsec if monotonic coarse, or just return with the proper
> + * values for realtime.
> + */
> + bne cr1,80f
> +
> + /* Add wall->monotonic offset and check for overflow or underflow */
> + add r4,r4,r6
> + add r5,r5,r9
> + cmpd cr0,r5,r7
> + cmpdi cr1,r5,0
> + blt 79f
> + subf r5,r7,r5
> + addi r4,r4,1
> +79: bge cr1,80f
> + addi r4,r4,-1
> + add r5,r5,r7
>
> 80: std r4,TSPC64_TV_SEC(r11)
> std r5,TSPC64_TV_NSEC(r11)
> --
> 2.13.5
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch
2017-10-06 9:03 ` [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Naveen N. Rao
@ 2017-10-06 10:13 ` Michael Ellerman
0 siblings, 0 replies; 15+ messages in thread
From: Michael Ellerman @ 2017-10-06 10:13 UTC (permalink / raw)
To: Naveen N. Rao, Santosh Sivaraj
Cc: linuxppc-dev, John Stultz, Thomas Gleixner, Frederic Weisbecker,
Srikar Dronamraju
Thanks for reviewing Naveen.
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> writes:
> On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
>> diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
>> index 382021324883..a0b4943811db 100644
>> --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
>> +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
>> @@ -60,18 +60,20 @@ V_FUNCTION_END(__kernel_gettimeofday)
>> */
>> V_FUNCTION_BEGIN(__kernel_clock_gettime)
>> .cfi_startproc
>> + mr r11,r4 /* r11 saves tp */
>> + mflr r12 /* r12 saves lr */
>> + lis r7,NSEC_PER_SEC@h /* want nanoseconds */
>> + ori r7,r7,NSEC_PER_SEC@l
>> +
>> /* Check for supported clock IDs */
>> cmpwi cr0,r3,CLOCK_REALTIME
>> cmpwi cr1,r3,CLOCK_MONOTONIC
>> cror cr0*4+eq,cr0*4+eq,cr1*4+eq
>> - bne cr0,99f
>> + beq cr0,49f
>>
>> - mflr r12 /* r12 saves lr */
>> + b 99f /* Fallback to syscall */
>
> 'beq', followed by a 'b' looks weird without considering the next patch.
> I think this can be organized better to not have to update r7/r11/r12 if
> using the system call. See next patch for my comments.
>
>> .cfi_register lr,r12
>
> If you move the mflr, you should move the above line along with it.
s/should/must/.
It literally says "lr is saved in r12".
cheers
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-09-18 9:23 ` [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
2017-10-06 9:28 ` Naveen N. Rao
@ 2017-10-06 11:25 ` Naveen N. Rao
2017-10-09 6:23 ` Santosh Sivaraj
2017-10-09 8:09 ` [PATCH v4] " Santosh Sivaraj
1 sibling, 2 replies; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-06 11:25 UTC (permalink / raw)
To: Santosh Sivaraj
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
> Current vDSO64 implementation does not have support for coarse clocks
> (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> to system call, increasing the response time, vDSO implementation reduces
> the cycle time. Below is a benchmark of the difference in execution time
> with and without vDSO support.
>
> (Non-coarse clocks are also included just for completion)
>
> Without vDSO support:
> --------------------
> clock-gettime-realtime: syscall: 172 nsec/call
> clock-gettime-realtime: libc: 26 nsec/call
> clock-gettime-realtime: vdso: 21 nsec/call
> clock-gettime-monotonic: syscall: 170 nsec/call
> clock-gettime-monotonic: libc: 30 nsec/call
> clock-gettime-monotonic: vdso: 24 nsec/call
> clock-gettime-realtime-coarse: syscall: 153 nsec/call
> clock-gettime-realtime-coarse: libc: 15 nsec/call
> clock-gettime-realtime-coarse: vdso: 9 nsec/call
> clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> clock-gettime-monotonic-coarse: libc: 15 nsec/call
> clock-gettime-monotonic-coarse: vdso: 11 nsec/call
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/kernel/asm-offsets.c | 2 ++
> arch/powerpc/kernel/vdso64/gettimeofday.S | 56 +++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+)
>
> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> index 8cfb20e38cfe..b55c68c54dc1 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -396,6 +396,8 @@ int main(void)
> /* Other bits used by the vdso */
> DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
>
> diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> index a0b4943811db..bae197a81add 100644
> --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> @@ -71,6 +71,11 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> beq cr0,49f
>
> + cmpwi cr0,r3,CLOCK_REALTIME_COARSE
> + cmpwi cr1,r3,CLOCK_MONOTONIC_COARSE
> + cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> + beq cr0,65f
> +
> b 99f /* Fallback to syscall */
> .cfi_register lr,r12
> 49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> @@ -112,6 +117,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> 1: bge cr1,80f
> addi r4,r4,-1
> add r5,r5,r7
> + b 80f
> +
> + /*
> + * For coarse clocks we get data directly from the vdso data page, so
> + * we don't need to call __do_get_tspec, but we still need to do the
> + * counter trick.
> + */
> +65: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> + andi. r0,r8,1 /* pending update ? loop */
> + bne- 70b
> + xor r0,r8,r8 /* create dependency */
> + add r3,r3,r0
> +
> + /*
> + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> + * too
> + */
> + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> + bne cr1,78f
> +
> + /* CLOCK_MONOTONIC_COARSE */
> + lwa r6,WTOM_CLOCK_SEC(r3)
> + lwa r9,WTOM_CLOCK_NSEC(r3)
> +
> + /* check if counter has updated */
> +78: or r0,r6,r9
> + xor r0,r0,r0
> + add r3,r3,r0
> + ld r0,CFG_TB_UPDATE_COUNT(r3)
> + cmpld cr0,r0,r8 /* check if updated */
> + bne- 70b
Don't you need a dependency on r4/r5 here for REALTIME_COARSE?
Something like:
/* check if counter has updated */
or r0,r6,r9
78: or r0,r4,r5
xor r0,r0,r0
> +
> + /* Counter has not updated, so continue calculating proper values for
> + * sec and nsec if monotonic coarse, or just return with the proper
> + * values for realtime.
> + */
> + bne cr1,80f
> +
I think the below hunk can surely be shared across the _COARSE and
regular clocks, if not more.
- Naveen
> + /* Add wall->monotonic offset and check for overflow or underflow */
> + add r4,r4,r6
> + add r5,r5,r9
> + cmpd cr0,r5,r7
> + cmpdi cr1,r5,0
> + blt 79f
> + subf r5,r7,r5
> + addi r4,r4,1
> +79: bge cr1,80f
> + addi r4,r4,-1
> + add r5,r5,r7
>
> 80: std r4,TSPC64_TV_SEC(r11)
> std r5,TSPC64_TV_NSEC(r11)
> --
> 2.13.5
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-06 11:25 ` Naveen N. Rao
@ 2017-10-09 6:23 ` Santosh Sivaraj
2017-10-09 8:09 ` [PATCH v4] " Santosh Sivaraj
1 sibling, 0 replies; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-09 6:23 UTC (permalink / raw)
To: Naveen N. Rao
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> wrote (on 2017-10-06 11:25:28 +0000):
> On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
> > Current vDSO64 implementation does not have support for coarse clocks
> > (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> > to system call, increasing the response time, vDSO implementation reduces
> > the cycle time. Below is a benchmark of the difference in execution time
> > with and without vDSO support.
> >
> > (Non-coarse clocks are also included just for completion)
> >
> > Without vDSO support:
> > --------------------
> > clock-gettime-realtime: syscall: 172 nsec/call
> > clock-gettime-realtime: libc: 26 nsec/call
> > clock-gettime-realtime: vdso: 21 nsec/call
> > clock-gettime-monotonic: syscall: 170 nsec/call
> > clock-gettime-monotonic: libc: 30 nsec/call
> > clock-gettime-monotonic: vdso: 24 nsec/call
> > clock-gettime-realtime-coarse: syscall: 153 nsec/call
> > clock-gettime-realtime-coarse: libc: 15 nsec/call
> > clock-gettime-realtime-coarse: vdso: 9 nsec/call
> > clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> > clock-gettime-monotonic-coarse: libc: 15 nsec/call
> > clock-gettime-monotonic-coarse: vdso: 11 nsec/call
> >
> > CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> > ---
> > arch/powerpc/kernel/asm-offsets.c | 2 ++
> > arch/powerpc/kernel/vdso64/gettimeofday.S | 56 +++++++++++++++++++++++++++++++
> > 2 files changed, 58 insertions(+)
> >
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> > index 8cfb20e38cfe..b55c68c54dc1 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -396,6 +396,8 @@ int main(void)
> > /* Other bits used by the vdso */
> > DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> > DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> > + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> > + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> > DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> > DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
> >
> > diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > index a0b4943811db..bae197a81add 100644
> > --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> > +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > @@ -71,6 +71,11 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> > beq cr0,49f
> >
> > + cmpwi cr0,r3,CLOCK_REALTIME_COARSE
> > + cmpwi cr1,r3,CLOCK_MONOTONIC_COARSE
> > + cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> > + beq cr0,65f
> > +
> > b 99f /* Fallback to syscall */
> > .cfi_register lr,r12
> > 49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> > @@ -112,6 +117,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > 1: bge cr1,80f
> > addi r4,r4,-1
> > add r5,r5,r7
> > + b 80f
> > +
> > + /*
> > + * For coarse clocks we get data directly from the vdso data page, so
> > + * we don't need to call __do_get_tspec, but we still need to do the
> > + * counter trick.
> > + */
> > +65: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> > +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> > + andi. r0,r8,1 /* pending update ? loop */
> > + bne- 70b
> > + xor r0,r8,r8 /* create dependency */
> > + add r3,r3,r0
> > +
> > + /*
> > + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> > + * too
> > + */
> > + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> > + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> > + bne cr1,78f
> > +
> > + /* CLOCK_MONOTONIC_COARSE */
> > + lwa r6,WTOM_CLOCK_SEC(r3)
> > + lwa r9,WTOM_CLOCK_NSEC(r3)
> > +
> > + /* check if counter has updated */
> > +78: or r0,r6,r9
> > + xor r0,r0,r0
> > + add r3,r3,r0
> > + ld r0,CFG_TB_UPDATE_COUNT(r3)
> > + cmpld cr0,r0,r8 /* check if updated */
> > + bne- 70b
>
> Don't you need a dependency on r4/r5 here for REALTIME_COARSE?
> Something like:
>
> /* check if counter has updated */
> or r0,r6,r9
> 78: or r0,r4,r5
> xor r0,r0,r0
>
Yes, we would need it. Will update in v2.
> > +
> > + /* Counter has not updated, so continue calculating proper values for
> > + * sec and nsec if monotonic coarse, or just return with the proper
> > + * values for realtime.
> > + */
> > + bne cr1,80f
> > +
>
> I think the below hunk can surely be shared across the _COARSE and
> regular clocks, if not more.
Yes, except for the label its the same for both monotonic and
monotonic_coarse, will update in the next set.
Thanks,
Santosh
>
> - Naveen
>
> > + /* Add wall->monotonic offset and check for overflow or underflow */
> > + add r4,r4,r6
> > + add r5,r5,r9
> > + cmpd cr0,r5,r7
> > + cmpdi cr1,r5,0
> > + blt 79f
> > + subf r5,r7,r5
> > + addi r4,r4,1
> > +79: bge cr1,80f
> > + addi r4,r4,-1
> > + add r5,r5,r7
> >
> > 80: std r4,TSPC64_TV_SEC(r11)
> > std r5,TSPC64_TV_NSEC(r11)
> > --
> > 2.13.5
> >
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-06 9:28 ` Naveen N. Rao
@ 2017-10-09 6:27 ` Santosh Sivaraj
0 siblings, 0 replies; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-09 6:27 UTC (permalink / raw)
To: Naveen N. Rao
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> wrote (on 2017-10-06 09:28:30 +0000):
> On 2017/09/18 09:23AM, Santosh Sivaraj wrote:
> > Current vDSO64 implementation does not have support for coarse clocks
> > (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> > to system call, increasing the response time, vDSO implementation reduces
> > the cycle time. Below is a benchmark of the difference in execution time
> > with and without vDSO support.
> >
> > (Non-coarse clocks are also included just for completion)
> >
> > Without vDSO support:
> > --------------------
> > clock-gettime-realtime: syscall: 172 nsec/call
> > clock-gettime-realtime: libc: 26 nsec/call
> > clock-gettime-realtime: vdso: 21 nsec/call
> > clock-gettime-monotonic: syscall: 170 nsec/call
> > clock-gettime-monotonic: libc: 30 nsec/call
> > clock-gettime-monotonic: vdso: 24 nsec/call
> > clock-gettime-realtime-coarse: syscall: 153 nsec/call
> > clock-gettime-realtime-coarse: libc: 15 nsec/call
> > clock-gettime-realtime-coarse: vdso: 9 nsec/call
> > clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> > clock-gettime-monotonic-coarse: libc: 15 nsec/call
> > clock-gettime-monotonic-coarse: vdso: 11 nsec/call
> >
> > CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> > ---
> > arch/powerpc/kernel/asm-offsets.c | 2 ++
> > arch/powerpc/kernel/vdso64/gettimeofday.S | 56 +++++++++++++++++++++++++++++++
> > 2 files changed, 58 insertions(+)
> >
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> > index 8cfb20e38cfe..b55c68c54dc1 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -396,6 +396,8 @@ int main(void)
> > /* Other bits used by the vdso */
> > DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> > DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> > + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> > + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> > DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> > DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
> >
> > diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > index a0b4943811db..bae197a81add 100644
> > --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> > +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > @@ -71,6 +71,11 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> > beq cr0,49f
> >
> > + cmpwi cr0,r3,CLOCK_REALTIME_COARSE
> > + cmpwi cr1,r3,CLOCK_MONOTONIC_COARSE
> > + cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> > + beq cr0,65f
>
> If you use cr5-7 here, you should be able to re-organize this to not
> have to update r4/r11/r12 if we're taking the syscall path. Not
> necessarily a huge win by itself, but can also help reuse some of the
> other code between the _COARSE and the regular variants.
>
If we are going to use cr5-7, then the first patch is no longer required, we
don't have to do a re-org of the intial clock_id checks. I will send the
updated patch.
Thanks,
Santosh
> - Naveen
>
> > +
> > b 99f /* Fallback to syscall */
> > .cfi_register lr,r12
> > 49: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> > @@ -112,6 +117,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > 1: bge cr1,80f
> > addi r4,r4,-1
> > add r5,r5,r7
> > + b 80f
> > +
> > + /*
> > + * For coarse clocks we get data directly from the vdso data page, so
> > + * we don't need to call __do_get_tspec, but we still need to do the
> > + * counter trick.
> > + */
> > +65: bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> > +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> > + andi. r0,r8,1 /* pending update ? loop */
> > + bne- 70b
> > + xor r0,r8,r8 /* create dependency */
> > + add r3,r3,r0
> > +
> > + /*
> > + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> > + * too
> > + */
> > + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> > + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> > + bne cr1,78f
> > +
> > + /* CLOCK_MONOTONIC_COARSE */
> > + lwa r6,WTOM_CLOCK_SEC(r3)
> > + lwa r9,WTOM_CLOCK_NSEC(r3)
> > +
> > + /* check if counter has updated */
> > +78: or r0,r6,r9
> > + xor r0,r0,r0
> > + add r3,r3,r0
> > + ld r0,CFG_TB_UPDATE_COUNT(r3)
> > + cmpld cr0,r0,r8 /* check if updated */
> > + bne- 70b
> > +
> > + /* Counter has not updated, so continue calculating proper values for
> > + * sec and nsec if monotonic coarse, or just return with the proper
> > + * values for realtime.
> > + */
> > + bne cr1,80f
> > +
> > + /* Add wall->monotonic offset and check for overflow or underflow */
> > + add r4,r4,r6
> > + add r5,r5,r9
> > + cmpd cr0,r5,r7
> > + cmpdi cr1,r5,0
> > + blt 79f
> > + subf r5,r7,r5
> > + addi r4,r4,1
> > +79: bge cr1,80f
> > + addi r4,r4,-1
> > + add r5,r5,r7
> >
> > 80: std r4,TSPC64_TV_SEC(r11)
> > std r5,TSPC64_TV_NSEC(r11)
> > --
> > 2.13.5
> >
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-06 11:25 ` Naveen N. Rao
2017-10-09 6:23 ` Santosh Sivaraj
@ 2017-10-09 8:09 ` Santosh Sivaraj
2017-10-09 10:39 ` Naveen N. Rao
1 sibling, 1 reply; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-09 8:09 UTC (permalink / raw)
To: linuxppc-dev
Cc: Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Naveen N. Rao, Srikar Dronamraju,
Benjamin Herrenschmidt
Current vDSO64 implementation does not have support for coarse clocks
(CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
to system call, increasing the response time, vDSO implementation reduces
the cycle time. Below is a benchmark of the difference in execution times.
(Non-coarse clocks are also included just for completion)
clock-gettime-realtime: syscall: 172 nsec/call
clock-gettime-realtime: libc: 28 nsec/call
clock-gettime-realtime: vdso: 22 nsec/call
clock-gettime-monotonic: syscall: 171 nsec/call
clock-gettime-monotonic: libc: 30 nsec/call
clock-gettime-monotonic: vdso: 25 nsec/call
clock-gettime-realtime-coarse: syscall: 153 nsec/call
clock-gettime-realtime-coarse: libc: 16 nsec/call
clock-gettime-realtime-coarse: vdso: 10 nsec/call
clock-gettime-monotonic-coarse: syscall: 167 nsec/call
clock-gettime-monotonic-coarse: libc: 17 nsec/call
clock-gettime-monotonic-coarse: vdso: 11 nsec/call
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
arch/powerpc/kernel/asm-offsets.c | 2 +
arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 8cfb20e38cfe..b55c68c54dc1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -396,6 +396,8 @@ int main(void)
/* Other bits used by the vdso */
DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
+ DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
+ DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 382021324883..729dded195ce 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -64,6 +64,12 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
cmpwi cr0,r3,CLOCK_REALTIME
cmpwi cr1,r3,CLOCK_MONOTONIC
cror cr0*4+eq,cr0*4+eq,cr1*4+eq
+
+ cmpwi cr5,r3,CLOCK_REALTIME_COARSE
+ cmpwi cr6,r3,CLOCK_MONOTONIC_COARSE
+ cror cr5*4+eq,cr5*4+eq,cr6*4+eq
+
+ cror cr0*4+eq,cr0*4+eq,cr5*4+eq
bne cr0,99f
mflr r12 /* r12 saves lr */
@@ -72,6 +78,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
bl V_LOCAL_FUNC(__get_datapage) /* get data page */
lis r7,NSEC_PER_SEC@h /* want nanoseconds */
ori r7,r7,NSEC_PER_SEC@l
+ beq cr5,70f
50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
bne cr1,80f /* if not monotonic, all done */
@@ -97,19 +104,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
ld r0,CFG_TB_UPDATE_COUNT(r3)
cmpld cr0,r0,r8 /* check if updated */
bne- 50b
+ b 78f
- /* Add wall->monotonic offset and check for overflow or underflow.
+ /*
+ * For coarse clocks we get data directly from the vdso data page, so
+ * we don't need to call __do_get_tspec, but we still need to do the
+ * counter trick.
*/
- add r4,r4,r6
- add r5,r5,r9
- cmpd cr0,r5,r7
- cmpdi cr1,r5,0
- blt 1f
- subf r5,r7,r5
- addi r4,r4,1
-1: bge cr1,80f
- addi r4,r4,-1
- add r5,r5,r7
+70: ld r8,CFG_TB_UPDATE_COUNT(r3)
+ andi. r0,r8,1 /* pending update ? loop */
+ bne- 70b
+ xor r0,r8,r8 /* create dependency */
+ add r3,r3,r0
+
+ /*
+ * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
+ * too
+ */
+ ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
+ ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
+ bne cr6,75f
+
+ /* CLOCK_MONOTONIC_COARSE */
+ lwa r6,WTOM_CLOCK_SEC(r3)
+ lwa r9,WTOM_CLOCK_NSEC(r3)
+
+ /* check if counter has updated */
+75: or r0,r6,r9
+ or r0,r4,r5
+ xor r0,r0,r0
+ add r3,r3,r0
+ ld r0,CFG_TB_UPDATE_COUNT(r3)
+ cmpld cr0,r0,r8 /* check if updated */
+ bne- 70b
+
+ /* Counter has not updated, so continue calculating proper values for
+ * sec and nsec if monotonic coarse, or just return with the proper
+ * values for realtime.
+ */
+ bne cr6,80f
+
+ /* Add wall->monotonic offset and check for overflow or underflow */
+78: add r4,r4,r6
+ add r5,r5,r9
+ cmpd cr0,r5,r7
+ cmpdi cr1,r5,0
+ blt 79f
+ subf r5,r7,r5
+ addi r4,r4,1
+79: bge cr1,80f
+ addi r4,r4,-1
+ add r5,r5,r7
80: std r4,TSPC64_TV_SEC(r11)
std r5,TSPC64_TV_NSEC(r11)
--
2.13.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v4] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-09 8:09 ` [PATCH v4] " Santosh Sivaraj
@ 2017-10-09 10:39 ` Naveen N. Rao
2017-10-10 9:03 ` Santosh Sivaraj
0 siblings, 1 reply; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-09 10:39 UTC (permalink / raw)
To: Santosh Sivaraj
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
On 2017/10/09 08:09AM, Santosh Sivaraj wrote:
> Current vDSO64 implementation does not have support for coarse clocks
> (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> to system call, increasing the response time, vDSO implementation reduces
> the cycle time. Below is a benchmark of the difference in execution times.
>
> (Non-coarse clocks are also included just for completion)
>
> clock-gettime-realtime: syscall: 172 nsec/call
> clock-gettime-realtime: libc: 28 nsec/call
> clock-gettime-realtime: vdso: 22 nsec/call
> clock-gettime-monotonic: syscall: 171 nsec/call
> clock-gettime-monotonic: libc: 30 nsec/call
> clock-gettime-monotonic: vdso: 25 nsec/call
> clock-gettime-realtime-coarse: syscall: 153 nsec/call
> clock-gettime-realtime-coarse: libc: 16 nsec/call
> clock-gettime-realtime-coarse: vdso: 10 nsec/call
> clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> clock-gettime-monotonic-coarse: libc: 17 nsec/call
> clock-gettime-monotonic-coarse: vdso: 11 nsec/call
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/kernel/asm-offsets.c | 2 +
> arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
> 2 files changed, 58 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> index 8cfb20e38cfe..b55c68c54dc1 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -396,6 +396,8 @@ int main(void)
> /* Other bits used by the vdso */
> DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
>
> diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> index 382021324883..729dded195ce 100644
> --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> @@ -64,6 +64,12 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> cmpwi cr0,r3,CLOCK_REALTIME
> cmpwi cr1,r3,CLOCK_MONOTONIC
> cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> +
> + cmpwi cr5,r3,CLOCK_REALTIME_COARSE
> + cmpwi cr6,r3,CLOCK_MONOTONIC_COARSE
> + cror cr5*4+eq,cr5*4+eq,cr6*4+eq
> +
> + cror cr0*4+eq,cr0*4+eq,cr5*4+eq
> bne cr0,99f
>
> mflr r12 /* r12 saves lr */
> @@ -72,6 +78,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> lis r7,NSEC_PER_SEC@h /* want nanoseconds */
> ori r7,r7,NSEC_PER_SEC@l
> + beq cr5,70f
> 50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
> bne cr1,80f /* if not monotonic, all done */
>
> @@ -97,19 +104,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> ld r0,CFG_TB_UPDATE_COUNT(r3)
> cmpld cr0,r0,r8 /* check if updated */
> bne- 50b
> + b 78f
>
> - /* Add wall->monotonic offset and check for overflow or underflow.
> + /*
> + * For coarse clocks we get data directly from the vdso data page, so
> + * we don't need to call __do_get_tspec, but we still need to do the
> + * counter trick.
> */
> - add r4,r4,r6
> - add r5,r5,r9
> - cmpd cr0,r5,r7
> - cmpdi cr1,r5,0
> - blt 1f
> - subf r5,r7,r5
> - addi r4,r4,1
> -1: bge cr1,80f
> - addi r4,r4,-1
> - add r5,r5,r7
> +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> + andi. r0,r8,1 /* pending update ? loop */
> + bne- 70b
> + xor r0,r8,r8 /* create dependency */
> + add r3,r3,r0
> +
> + /*
> + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> + * too
> + */
> + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> + bne cr6,75f
> +
> + /* CLOCK_MONOTONIC_COARSE */
> + lwa r6,WTOM_CLOCK_SEC(r3)
> + lwa r9,WTOM_CLOCK_NSEC(r3)
> +
> + /* check if counter has updated */
> +75: or r0,r6,r9
> + or r0,r4,r5
> + xor r0,r0,r0
The label '75:' should be on the second instruction since we don't need
to worry about r6/r9 for REALTIME_COARSE.
Also, the above hunk should actually be:
or r0,r6,r9
or r0,r0,r4
or r0,r0,r5
xor r0,r0,r0
Otherwise, the first 'or' will be skipped. I realized this after I
replied to your previous version, but missed letting you know...
> + add r3,r3,r0
> + ld r0,CFG_TB_UPDATE_COUNT(r3)
> + cmpld cr0,r0,r8 /* check if updated */
> + bne- 70b
I also notice that the code for dealing with CLOCK_MONOTONIC is similar
for _COARSE and regular clocks. If possible, we should reuse that as
well.
- Naveen
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-09 10:39 ` Naveen N. Rao
@ 2017-10-10 9:03 ` Santosh Sivaraj
2017-10-10 9:30 ` Naveen N. Rao
0 siblings, 1 reply; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-10 9:03 UTC (permalink / raw)
To: Naveen N. Rao; +Cc: linuxppc-dev, Michael Ellerman, Srikar Dronamraju
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> wrote (on 2017-10-09 10:39:18 +0000):
> On 2017/10/09 08:09AM, Santosh Sivaraj wrote:
> > Current vDSO64 implementation does not have support for coarse clocks
> > (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> > to system call, increasing the response time, vDSO implementation reduces
> > the cycle time. Below is a benchmark of the difference in execution times.
> >
> > (Non-coarse clocks are also included just for completion)
> >
> > clock-gettime-realtime: syscall: 172 nsec/call
> > clock-gettime-realtime: libc: 28 nsec/call
> > clock-gettime-realtime: vdso: 22 nsec/call
> > clock-gettime-monotonic: syscall: 171 nsec/call
> > clock-gettime-monotonic: libc: 30 nsec/call
> > clock-gettime-monotonic: vdso: 25 nsec/call
> > clock-gettime-realtime-coarse: syscall: 153 nsec/call
> > clock-gettime-realtime-coarse: libc: 16 nsec/call
> > clock-gettime-realtime-coarse: vdso: 10 nsec/call
> > clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> > clock-gettime-monotonic-coarse: libc: 17 nsec/call
> > clock-gettime-monotonic-coarse: vdso: 11 nsec/call
> >
> > CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> > ---
> > arch/powerpc/kernel/asm-offsets.c | 2 +
> > arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
> > 2 files changed, 58 insertions(+), 11 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> > index 8cfb20e38cfe..b55c68c54dc1 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -396,6 +396,8 @@ int main(void)
> > /* Other bits used by the vdso */
> > DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
> > DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
> > + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
> > + DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
> > DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
> > DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
> >
> > diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > index 382021324883..729dded195ce 100644
> > --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> > +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > @@ -64,6 +64,12 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > cmpwi cr0,r3,CLOCK_REALTIME
> > cmpwi cr1,r3,CLOCK_MONOTONIC
> > cror cr0*4+eq,cr0*4+eq,cr1*4+eq
> > +
> > + cmpwi cr5,r3,CLOCK_REALTIME_COARSE
> > + cmpwi cr6,r3,CLOCK_MONOTONIC_COARSE
> > + cror cr5*4+eq,cr5*4+eq,cr6*4+eq
> > +
> > + cror cr0*4+eq,cr0*4+eq,cr5*4+eq
> > bne cr0,99f
> >
> > mflr r12 /* r12 saves lr */
> > @@ -72,6 +78,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > bl V_LOCAL_FUNC(__get_datapage) /* get data page */
> > lis r7,NSEC_PER_SEC@h /* want nanoseconds */
> > ori r7,r7,NSEC_PER_SEC@l
> > + beq cr5,70f
> > 50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
> > bne cr1,80f /* if not monotonic, all done */
> >
> > @@ -97,19 +104,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
> > ld r0,CFG_TB_UPDATE_COUNT(r3)
> > cmpld cr0,r0,r8 /* check if updated */
> > bne- 50b
> > + b 78f
> >
> > - /* Add wall->monotonic offset and check for overflow or underflow.
> > + /*
> > + * For coarse clocks we get data directly from the vdso data page, so
> > + * we don't need to call __do_get_tspec, but we still need to do the
> > + * counter trick.
> > */
> > - add r4,r4,r6
> > - add r5,r5,r9
> > - cmpd cr0,r5,r7
> > - cmpdi cr1,r5,0
> > - blt 1f
> > - subf r5,r7,r5
> > - addi r4,r4,1
> > -1: bge cr1,80f
> > - addi r4,r4,-1
> > - add r5,r5,r7
> > +70: ld r8,CFG_TB_UPDATE_COUNT(r3)
> > + andi. r0,r8,1 /* pending update ? loop */
> > + bne- 70b
> > + xor r0,r8,r8 /* create dependency */
> > + add r3,r3,r0
> > +
> > + /*
> > + * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
> > + * too
> > + */
> > + ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
> > + ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
> > + bne cr6,75f
> > +
> > + /* CLOCK_MONOTONIC_COARSE */
> > + lwa r6,WTOM_CLOCK_SEC(r3)
> > + lwa r9,WTOM_CLOCK_NSEC(r3)
> > +
> > + /* check if counter has updated */
> > +75: or r0,r6,r9
> > + or r0,r4,r5
> > + xor r0,r0,r0
>
> The label '75:' should be on the second instruction since we don't need
> to worry about r6/r9 for REALTIME_COARSE.
>
> Also, the above hunk should actually be:
>
> or r0,r6,r9
> or r0,r0,r4
> or r0,r0,r5
> xor r0,r0,r0
>
> Otherwise, the first 'or' will be skipped. I realized this after I
> replied to your previous version, but missed letting you know...
Yeah, I too missed it.
>
> > + add r3,r3,r0
> > + ld r0,CFG_TB_UPDATE_COUNT(r3)
> > + cmpld cr0,r0,r8 /* check if updated */
> > + bne- 70b
>
> I also notice that the code for dealing with CLOCK_MONOTONIC is similar
> for _COARSE and regular clocks. If possible, we should reuse that as
> well.
>
In this case we will be adding more checks and branches in order to reuse
the code. If we want to keep the code common we will have to do a lot of
jumping around, code will contain a bunch of branches, which I feel will make
the code/flow hard to understand. (Q: Does lot of branches have bad effect on
branch prediction?)
Will wait for your thoughts, before respinning.
Thanks,
Santosh
>
> - Naveen
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-10 9:03 ` Santosh Sivaraj
@ 2017-10-10 9:30 ` Naveen N. Rao
2017-10-10 23:10 ` [PATCH v6] " Santosh Sivaraj
0 siblings, 1 reply; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-10 9:30 UTC (permalink / raw)
To: Santosh Sivaraj; +Cc: linuxppc-dev, Michael Ellerman, Srikar Dronamraju
On 2017/10/10 09:03AM, Santosh Sivaraj wrote:
> * Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> wrote (on 2017-10-09 10:39:18 +0000):
>
> > On 2017/10/09 08:09AM, Santosh Sivaraj wrote:
[snip]
> > > + add r3,r3,r0
> > > + ld r0,CFG_TB_UPDATE_COUNT(r3)
> > > + cmpld cr0,r0,r8 /* check if updated */
> > > + bne- 70b
> >
> > I also notice that the code for dealing with CLOCK_MONOTONIC is similar
> > for _COARSE and regular clocks. If possible, we should reuse that as
> > well.
> >
> In this case we will be adding more checks and branches in order to reuse
> the code. If we want to keep the code common we will have to do a lot of
> jumping around, code will contain a bunch of branches, which I feel will make
> the code/flow hard to understand. (Q: Does lot of branches have bad effect on
> branch prediction?)
Right - like we discussed offline, if it hurts readability, that's a
good enough reason not to do this. We are only talking about a few
instructions here anyway, so no need to worry too much.
- Naveen
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v6] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-10 9:30 ` Naveen N. Rao
@ 2017-10-10 23:10 ` Santosh Sivaraj
2017-10-11 7:04 ` Naveen N. Rao
0 siblings, 1 reply; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-10 23:10 UTC (permalink / raw)
To: linuxppc-dev
Cc: Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Naveen N. Rao, Srikar Dronamraju,
Benjamin Herrenschmidt
Current vDSO64 implementation does not have support for coarse clocks
(CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
to system call, increasing the response time, vDSO implementation reduces
the cycle time. Below is a benchmark of the difference in execution times.
(Non-coarse clocks are also included just for completion)
clock-gettime-realtime: syscall: 172 nsec/call
clock-gettime-realtime: libc: 28 nsec/call
clock-gettime-realtime: vdso: 22 nsec/call
clock-gettime-monotonic: syscall: 171 nsec/call
clock-gettime-monotonic: libc: 30 nsec/call
clock-gettime-monotonic: vdso: 25 nsec/call
clock-gettime-realtime-coarse: syscall: 153 nsec/call
clock-gettime-realtime-coarse: libc: 16 nsec/call
clock-gettime-realtime-coarse: vdso: 10 nsec/call
clock-gettime-monotonic-coarse: syscall: 167 nsec/call
clock-gettime-monotonic-coarse: libc: 17 nsec/call
clock-gettime-monotonic-coarse: vdso: 11 nsec/call
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
arch/powerpc/kernel/asm-offsets.c | 2 +
arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 8cfb20e38cfe..b55c68c54dc1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -396,6 +396,8 @@ int main(void)
/* Other bits used by the vdso */
DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
+ DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
+ DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 382021324883..b594f5c745fa 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -64,6 +64,12 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
cmpwi cr0,r3,CLOCK_REALTIME
cmpwi cr1,r3,CLOCK_MONOTONIC
cror cr0*4+eq,cr0*4+eq,cr1*4+eq
+
+ cmpwi cr5,r3,CLOCK_REALTIME_COARSE
+ cmpwi cr6,r3,CLOCK_MONOTONIC_COARSE
+ cror cr5*4+eq,cr5*4+eq,cr6*4+eq
+
+ cror cr0*4+eq,cr0*4+eq,cr5*4+eq
bne cr0,99f
mflr r12 /* r12 saves lr */
@@ -72,6 +78,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
bl V_LOCAL_FUNC(__get_datapage) /* get data page */
lis r7,NSEC_PER_SEC@h /* want nanoseconds */
ori r7,r7,NSEC_PER_SEC@l
+ beq cr5,70f
50: bl V_LOCAL_FUNC(__do_get_tspec) /* get time from tb & kernel */
bne cr1,80f /* if not monotonic, all done */
@@ -97,19 +104,57 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
ld r0,CFG_TB_UPDATE_COUNT(r3)
cmpld cr0,r0,r8 /* check if updated */
bne- 50b
+ b 78f
- /* Add wall->monotonic offset and check for overflow or underflow.
+ /*
+ * For coarse clocks we get data directly from the vdso data page, so
+ * we don't need to call __do_get_tspec, but we still need to do the
+ * counter trick.
*/
- add r4,r4,r6
- add r5,r5,r9
- cmpd cr0,r5,r7
- cmpdi cr1,r5,0
- blt 1f
- subf r5,r7,r5
- addi r4,r4,1
-1: bge cr1,80f
- addi r4,r4,-1
- add r5,r5,r7
+70: ld r8,CFG_TB_UPDATE_COUNT(r3)
+ andi. r0,r8,1 /* pending update ? loop */
+ bne- 70b
+ xor r0,r8,r8 /* create dependency */
+ add r3,r3,r0
+
+ /*
+ * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE
+ * too
+ */
+ ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
+ ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
+ bne cr6,75f
+
+ /* CLOCK_MONOTONIC_COARSE */
+ lwa r6,WTOM_CLOCK_SEC(r3)
+ lwa r9,WTOM_CLOCK_NSEC(r3)
+
+ /* check if counter has updated */
+ or r0,r6,r9
+75: or r0,r4,r5
+ xor r0,r0,r0
+ add r3,r3,r0
+ ld r0,CFG_TB_UPDATE_COUNT(r3)
+ cmpld cr0,r0,r8 /* check if updated */
+ bne- 70b
+
+ /* Counter has not updated, so continue calculating proper values for
+ * sec and nsec if monotonic coarse, or just return with the proper
+ * values for realtime.
+ */
+ bne cr6,80f
+
+ /* Add wall->monotonic offset and check for overflow or underflow */
+78: add r4,r4,r6
+ add r5,r5,r9
+ cmpd cr0,r5,r7
+ cmpdi cr1,r5,0
+ blt 79f
+ subf r5,r7,r5
+ addi r4,r4,1
+79: bge cr1,80f
+ addi r4,r4,-1
+ add r5,r5,r7
80: std r4,TSPC64_TV_SEC(r11)
std r5,TSPC64_TV_NSEC(r11)
--
2.13.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v6] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-10 23:10 ` [PATCH v6] " Santosh Sivaraj
@ 2017-10-11 7:04 ` Naveen N. Rao
2017-10-11 7:38 ` Santosh Sivaraj
0 siblings, 1 reply; 15+ messages in thread
From: Naveen N. Rao @ 2017-10-11 7:04 UTC (permalink / raw)
To: Santosh Sivaraj
Cc: linuxppc-dev, Michael Ellerman, John Stultz, Thomas Gleixner,
Frederic Weisbecker, Srikar Dronamraju, Benjamin Herrenschmidt
Hi Santosh,
This seems to have gone from v4 to v6 -- did I miss v5?
On 2017/10/10 11:10PM, Santosh Sivaraj wrote:
> Current vDSO64 implementation does not have support for coarse clocks
> (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> to system call, increasing the response time, vDSO implementation reduces
> the cycle time. Below is a benchmark of the difference in execution times.
>
> (Non-coarse clocks are also included just for completion)
>
> clock-gettime-realtime: syscall: 172 nsec/call
> clock-gettime-realtime: libc: 28 nsec/call
> clock-gettime-realtime: vdso: 22 nsec/call
> clock-gettime-monotonic: syscall: 171 nsec/call
> clock-gettime-monotonic: libc: 30 nsec/call
> clock-gettime-monotonic: vdso: 25 nsec/call
> clock-gettime-realtime-coarse: syscall: 153 nsec/call
> clock-gettime-realtime-coarse: libc: 16 nsec/call
> clock-gettime-realtime-coarse: vdso: 10 nsec/call
> clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> clock-gettime-monotonic-coarse: libc: 17 nsec/call
> clock-gettime-monotonic-coarse: vdso: 11 nsec/call
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/kernel/asm-offsets.c | 2 +
> arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
> 2 files changed, 58 insertions(+), 11 deletions(-)
... and no changes since the last rev?
It is better to post new versions in a separate thread and to include
the changelog for easier review.
- Naveen
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
2017-10-11 7:04 ` Naveen N. Rao
@ 2017-10-11 7:38 ` Santosh Sivaraj
0 siblings, 0 replies; 15+ messages in thread
From: Santosh Sivaraj @ 2017-10-11 7:38 UTC (permalink / raw)
To: Naveen N. Rao; +Cc: linuxppc-dev
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> wrote (on 2017-10-11 07:04:43 +0000):
> Hi Santosh,
> This seems to have gone from v4 to v6 -- did I miss v5?
Nope, this is indeed v5, a typo :-(
>
> On 2017/10/10 11:10PM, Santosh Sivaraj wrote:
> > Current vDSO64 implementation does not have support for coarse clocks
> > (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls back
> > to system call, increasing the response time, vDSO implementation reduces
> > the cycle time. Below is a benchmark of the difference in execution times.
> >
> > (Non-coarse clocks are also included just for completion)
> >
> > clock-gettime-realtime: syscall: 172 nsec/call
> > clock-gettime-realtime: libc: 28 nsec/call
> > clock-gettime-realtime: vdso: 22 nsec/call
> > clock-gettime-monotonic: syscall: 171 nsec/call
> > clock-gettime-monotonic: libc: 30 nsec/call
> > clock-gettime-monotonic: vdso: 25 nsec/call
> > clock-gettime-realtime-coarse: syscall: 153 nsec/call
> > clock-gettime-realtime-coarse: libc: 16 nsec/call
> > clock-gettime-realtime-coarse: vdso: 10 nsec/call
> > clock-gettime-monotonic-coarse: syscall: 167 nsec/call
> > clock-gettime-monotonic-coarse: libc: 17 nsec/call
> > clock-gettime-monotonic-coarse: vdso: 11 nsec/call
> >
> > CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> > ---
> > arch/powerpc/kernel/asm-offsets.c | 2 +
> > arch/powerpc/kernel/vdso64/gettimeofday.S | 67 ++++++++++++++++++++++++++-----
> > 2 files changed, 58 insertions(+), 11 deletions(-)
>
> ... and no changes since the last rev?
There is that one line change of label. But otherwise its the same.
>
> It is better to post new versions in a separate thread and to include
> the changelog for easier review.
>
Sure.
Thanks,
Santosh
>
> - Naveen
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-10-11 7:38 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-18 9:23 [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Santosh Sivaraj
2017-09-18 9:23 ` [PATCH 2/2] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
2017-10-06 9:28 ` Naveen N. Rao
2017-10-09 6:27 ` Santosh Sivaraj
2017-10-06 11:25 ` Naveen N. Rao
2017-10-09 6:23 ` Santosh Sivaraj
2017-10-09 8:09 ` [PATCH v4] " Santosh Sivaraj
2017-10-09 10:39 ` Naveen N. Rao
2017-10-10 9:03 ` Santosh Sivaraj
2017-10-10 9:30 ` Naveen N. Rao
2017-10-10 23:10 ` [PATCH v6] " Santosh Sivaraj
2017-10-11 7:04 ` Naveen N. Rao
2017-10-11 7:38 ` Santosh Sivaraj
2017-10-06 9:03 ` [PATCH 1/2] powerpc/vdso64: Coarse timer support preparatory patch Naveen N. Rao
2017-10-06 10:13 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.