From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
arnd@arndb.de, tglx@linutronix.de, vincenzo.frascino@arm.com,
luto@kernel.org
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
x86@kernel.org
Subject: [RFC PATCH v3 12/12] powerpc/vdso: provide __arch_is_hw_counter_valid()
Date: Mon, 13 Jan 2020 17:08:50 +0000 (UTC) [thread overview]
Message-ID: <980b880ed9a86342e05cee18e1b2ce66fbe92d4c.1578934751.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1578934751.git.christophe.leroy@c-s.fr>
To avoid a double verification of the hw_counter validity,
provide __arch_is_hw_counter_valid()
Before:
clock-gettime-realtime: vdso: 1078 nsec/call
After:
clock-gettime-realtime: vdso: 1064 nsec/call
The * shows the test of the clock type.
The > shows the additional test on the counter,
that goes away with this patch
Before:
5e0: 81 25 00 04 lwz r9,4(r5)
*5e4: 2f 89 00 00 cmpwi cr7,r9,0
*5e8: 40 9e 01 3c bne cr7,724 <__c_kernel_clock_gettime+0x17c>
5ec: 94 21 ff e0 stwu r1,-32(r1)
5f0: 93 61 00 0c stw r27,12(r1)
5f4: 93 81 00 10 stw r28,16(r1)
5f8: 93 a1 00 14 stw r29,20(r1)
5fc: 93 c1 00 18 stw r30,24(r1)
600: 93 e1 00 1c stw r31,28(r1)
604: 7d 8d 42 e6 mftbu r12
608: 7f ac 42 e6 mftb r29
60c: 7c cd 42 e6 mftbu r6
610: 7f 8c 30 40 cmplw cr7,r12,r6
614: 40 9e ff f0 bne cr7,604 <__c_kernel_clock_gettime+0x5c>
>618: 2f 8c 00 00 cmpwi cr7,r12,0
61c: 83 6b 00 28 lwz r27,40(r11)
620: 83 8b 00 2c lwz r28,44(r11)
624: 81 45 00 08 lwz r10,8(r5)
628: 80 e5 00 0c lwz r7,12(r5)
>62c: 41 9c 00 b4 blt cr7,6e0 <__c_kernel_clock_gettime+0x138>
630: 81 05 00 18 lwz r8,24(r5)
634: 83 c5 00 1c lwz r30,28(r5)
638: 80 cb 00 24 lwz r6,36(r11)
63c: 83 e5 00 00 lwz r31,0(r5)
640: 7f 9f 00 40 cmplw cr7,r31,r0
644: 40 9e 00 84 bne cr7,6c8 <__c_kernel_clock_gettime+0x120>
After:
5e0: 81 25 00 04 lwz r9,4(r5)
*5e4: 2f 89 00 00 cmpwi cr7,r9,0
*5e8: 40 9e 01 88 bne cr7,770 <__c_kernel_clock_gettime+0x1c8>
5ec: 94 21 ff e0 stwu r1,-32(r1)
5f0: 93 61 00 0c stw r27,12(r1)
5f4: 93 81 00 10 stw r28,16(r1)
5f8: 93 a1 00 14 stw r29,20(r1)
5fc: 93 c1 00 18 stw r30,24(r1)
600: 93 e1 00 1c stw r31,28(r1)
604: 7f cd 42 e6 mftbu r30
608: 7f ac 42 e6 mftb r29
60c: 7c cd 42 e6 mftbu r6
610: 7f 9e 30 40 cmplw cr7,r30,r6
614: 40 9e ff f0 bne cr7,604 <__c_kernel_clock_gettime+0x5c>
618: 83 6b 00 28 lwz r27,40(r11)
61c: 83 8b 00 2c lwz r28,44(r11)
620: 81 45 00 08 lwz r10,8(r5)
624: 80 e5 00 0c lwz r7,12(r5)
628: 81 05 00 18 lwz r8,24(r5)
62c: 83 e5 00 1c lwz r31,28(r5)
630: 80 cb 00 24 lwz r6,36(r11)
634: 81 85 00 00 lwz r12,0(r5)
638: 7f 8c 00 40 cmplw cr7,r12,r0
63c: 40 9e 00 84 bne cr7,6c0 <__c_kernel_clock_gettime+0x118>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/vdso/gettimeofday.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index d1e702e0ea86..c5a24f31382e 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -69,15 +69,18 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
}
#endif
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+static __always_inline bool __arch_is_hw_counter_valid(s32 clock_mode)
{
/*
* clock_mode == 0 implies that vDSO are enabled otherwise
* fallback on syscall.
*/
- if (clock_mode != 0)
- return U64_MAX;
+ return clock_mode == 0 ? true : false;
+}
+#define __arch_is_hw_counter_valid __arch_is_hw_counter_valid
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+{
return get_tb();
}
--
2.13.3
prev parent reply other threads:[~2020-01-13 17:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 17:08 [RFC PATCH v3 00/12] powerpc: switch VDSO to C implementation Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 01/12] powerpc/64: Don't provide time functions in compat VDSO32 Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 02/12] powerpc/vdso: Switch VDSO to generic C implementation Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 03/12] lib: vdso: mark __cvdso_clock_getres() as static Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 04/12] lib: vdso: inline do_hres() and do_coarse() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 05/12] lib: vdso: Avoid duplication in __cvdso_clock_getres() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 06/12] lib: vdso: __iter_div_u64_rem() is suboptimal for 32 bit time Christophe Leroy
2020-01-14 11:31 ` Thomas Gleixner
2020-01-13 17:08 ` [RFC PATCH v3 07/12] powerpc/vdso: simplify __get_datapage() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 08/12] lib: vdso: allow arches to provide vdso data pointer Christophe Leroy
2020-01-14 23:06 ` Thomas Gleixner
2020-01-15 6:15 ` Christophe Leroy
2020-01-16 9:16 ` Christophe Leroy
2020-01-16 10:35 ` Thomas Gleixner
2020-01-16 20:22 ` Andy Lutomirski
2020-01-13 17:08 ` [RFC PATCH v3 09/12] powerpc/vdso: provide inline alternative to __get_datapage() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 10/12] powerpc/vdso: provide vdso data pointer from the ASM caller Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 11/12] lib: vdso: split clock verification out of __arch_get_hw_counter() Christophe Leroy
2020-01-13 17:08 ` Christophe Leroy [this message]
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=980b880ed9a86342e05cee18e1b2ce66fbe92d4c.1578934751.git.christophe.leroy@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).