[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <fc1ff722c7cbe63a63ae02ade3a714d2049d54a5.1577111367.git.christophe.leroy@c-s.fr>
Date: Mon, 23 Dec 2019 14:31:08 +0000 (UTC)
From: Christophe Leroy <christophe.leroy@....fr>
To: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>, arnd@...db.de,
tglx@...utronix.de, vincenzo.frascino@....com, luto@...nel.org
Cc: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-arm-kernel@...ts.infradead.org, linux-mips@...r.kernel.org,
x86@...nel.org
Subject: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in
__c_kernel_time()
READ_ONCE() forces the read of the 64 bit value of
vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough
only the lower part is needed.
This results in a suboptimal code:
00000af4 <__c_kernel_time>:
af4: 2c 03 00 00 cmpwi r3,0
af8: 81 44 00 20 lwz r10,32(r4)
afc: 81 64 00 24 lwz r11,36(r4)
b00: 41 82 00 08 beq b08 <__c_kernel_time+0x14>
b04: 91 63 00 00 stw r11,0(r3)
b08: 7d 63 5b 78 mr r3,r11
b0c: 4e 80 00 20 blr
By removing the READ_ONCE(), only the lower part is read from
memory, and the code is cleaner:
00000af4 <__c_kernel_time>:
af4: 7c 69 1b 79 mr. r9,r3
af8: 80 64 00 24 lwz r3,36(r4)
afc: 4d 82 00 20 beqlr
b00: 90 69 00 00 stw r3,0(r9)
b04: 4e 80 00 20 blr
Signed-off-by: Christophe Leroy <christophe.leroy@....fr>
---
lib/vdso/gettimeofday.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 17b4cff6e5f0..5a17a9d2e6cd 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -144,7 +144,7 @@ __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tv
static __maybe_unused __kernel_old_time_t
__cvdso_time(const struct vdso_data *vd, __kernel_old_time_t *time)
{
- __kernel_old_time_t t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
+ __kernel_old_time_t t = vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec;
if (time)
*time = t;
--
2.13.3
Powered by blists - more mailing lists