On Sun, 2014-02-02 at 07:43 -0800, H. Peter Anvin wrote:
> Even reading the timezone via gettimeofday is the uncommon case... never mind 
> only the timezome.  Whatever you do please don't slow down the common case.
> 
> On February 2, 2014 3:27:13 AM PST, stef...@seibold.net wrote:
> >From: Stefani Seibold <stef...@seibold.net>
> >
> >This patch do a little cleanup for the __vdso_gettimeofday() function.
> >
> >It kick out an unneeded ret local variable and makes the code faster if
> >only the timezone is needed.
> >
> >Signed-off-by: Stefani Seibold <stef...@seibold.net>
> >---
> > arch/x86/vdso/vclock_gettime.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> >diff --git a/arch/x86/vdso/vclock_gettime.c
> >b/arch/x86/vdso/vclock_gettime.c
> >index 743f277..bf969a0 100644
> >--- a/arch/x86/vdso/vclock_gettime.c
> >+++ b/arch/x86/vdso/vclock_gettime.c
> >@@ -259,13 +259,12 @@ int clock_gettime(clockid_t, struct timespec *)
> > 
> >notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone
> >*tz)
> > {
> >-    long ret = VCLOCK_NONE;
> >-
> >     if (likely(tv != NULL)) {
> >             BUILD_BUG_ON(offsetof(struct timeval, tv_usec) !=
> >                          offsetof(struct timespec, tv_nsec) ||
> >                          sizeof(*tv) != sizeof(struct timespec));
> >-            ret = do_realtime((struct timespec *)tv);
> >+            if (do_realtime((struct timespec *)tv) == VCLOCK_NONE)
> >+                    return vdso_fallback_gtod(tv, tz);
> >             tv->tv_usec /= 1000;
> >     }
> >     if (unlikely(tz != NULL)) {
> >@@ -274,8 +273,6 @@ notrace int __vdso_gettimeofday(struct timeval *tv,
> >struct timezone *tz)
> >             tz->tz_dsttime = gtod->sys_tz.tz_dsttime;
> >     }
> > 
> >-    if (ret == VCLOCK_NONE)
> >-            return vdso_fallback_gtod(tv, tz);
> >     return 0;
> > }
> > int gettimeofday(struct timeval *, struct timezone *)
> 

I don't see where i slow down the common case! It is exactly the same
behaviour as the original code. Only in the uncommon case where the tv
== NULL and tz != NULL is a bit faster.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to