From patchwork Thu Oct 19 11:14:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 116366 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp367280qgn; Thu, 19 Oct 2017 04:17:00 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QQP4LtixzmlrG+UDl7FaS8Srdrzw2dGtW5fVVYwvCvs+ojvaBExN5A0IScATMya5OQ5j8T X-Received: by 10.98.200.138 with SMTP id i10mr1195643pfk.222.1508411820108; Thu, 19 Oct 2017 04:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508411820; cv=none; d=google.com; s=arc-20160816; b=TY8rV3IkeHDd7grFxunZ20boHW6NTPLH7aF0W8z60Pp5zEIywOknC9pdEGZYu392LM ra2o3glFOCFwZ0+O2cWUQfe6Dr2p5W54h5NKs4mAAlF5WdUp69EeL/Z0RjkBCTC89cB7 cXwlRWe6bBjhdn5yrqmJxAvsm6GaW+GkL1IZWeYTMg+GFXK/HA3SpbzJPb2tDDDBJ697 VyXuh78eQWgmy7lN6hhjxo1C/Odw6hr3USKMWvlZaVzwX5bGiG0yKgLL40XHocD4udoC ljjgft3ZyqYb4P7rZB8vXBdcH/EBUAnyo3AnliTOdpDFd6wxYTL7n1r7AzUtdW/ZId8f D+tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1/IOOkOEWUBWUNMmHxV3XifOBsNCTYLIZJUMwbhjrCM=; b=mcbRMBVVQ5Zzfsnuc2ihgqfdM897XvDF6r7Nb6wLqkBHXziEIe9dHlPd7XmRMs70na 6z/zosj9Yr0MVkw176Bea2hMj4Mvbkn5UnoO1PG9KQY3A8xEKEgsYBW6BEgjyCzzLnC3 sR1yiunxGgbZMK7BO2J5HikoB99JVUu/etmwChUIlvF/GyKp+9Fc6a/UAVA5p7spDwMt 0GrtS0MgYBiGiJDldRK5KHRajzZh6P0JFrLM9+aCrSNUbMM5yGE5pkLrCwOHjzcZuk36 xR7axe3ezU5L6XtSAVeQJ4opY4dlEpkYml1xMcOrTBquM6CJULPdWyS6VKebVq531fU1 kCJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si2139490plm.122.2017.10.19.04.16.59; Thu, 19 Oct 2017 04:17:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752794AbdJSLPi (ORCPT + 27 others); Thu, 19 Oct 2017 07:15:38 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:58342 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752674AbdJSLPQ (ORCPT ); Thu, 19 Oct 2017 07:15:16 -0400 Received: from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0LtWRI-1d6cD00NMq-010wTB; Thu, 19 Oct 2017 13:15:06 +0200 From: Arnd Bergmann To: Thomas Gleixner , y2038@lists.linaro.org Cc: Deepa Dinamani , John Stultz , Stephen Boyd , linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH 7/7] time: remove timespec64 hack Date: Thu, 19 Oct 2017 13:14:50 +0200 Message-Id: <20171019111450.3702205-7-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171019111450.3702205-1-arnd@arndb.de> References: <20171019111450.3702205-1-arnd@arndb.de> X-Provags-ID: V03:K0:5EY9rbrnP1hu1GWdqezLZ0SK0qbu8caFKXlQI5fy/66AoZaNdH4 6Cjf33RLKiSRLz06y7enrT04937VsJJAEY6DS9/ieBNm+CPexzJUz+1YNvjGdVwBhYBY0CN Q2OLay4g7RB13QJcF/Mj2S2MBbXsNp4vH0yP8I9LikOcUFxDvqzwORUTqApmYebED9OtWer /8FG8aZJpQ7mluE1Xh3ng== X-UI-Out-Filterresults: notjunk:1; V01:K0:G+/utopfuAk=:Gs/6RLpNeQry+mh/k6VxHr zB3uBg2Ol28Fv4HDgeLrLw9+lQC2DXbbCVhPLareUfuhmmDB8nZyf+8mDofA3JekoekCKxZVF frKfKCsONnF8inWYb57uQcm+TW/peMBjEerMYeP6f9XMGemvyKP6XP27MlkvUqycKlnVbBuWv u6Sf3Uxu01n/I9rQFHY7eHZrqZizZzAQefNjkYY5vBtiozjgUviS5rftmLQJAnmLA90Us2dKP /nbITXAr8a9eXeSZwUxyIgOmMYwPbqOfHu9/2d0ndEmVPANLIGAK2uV+xzlh+QIy5hTwjHCYT 70V+JD/jk03Rtiu3YxeXSXEjczLb6i/vMiWrvWDXqjxVyePXAQXGSbBQ04roYWmQroRlTDrJ3 J9WIgKx71HF52OrseFU+NG78tDmxfZ+wyJf3Nh5ElTyeOjS3f2GTBkcqLZFFeYRo+r20LJQJE KRB/XFEKACGqjW3Bm5j6b9fP1EzEEH+GGWeIC9wxIW0kwK+x9sHtQ5av5EbfB7EXJQCdDT6H5 5ZRvQNjekbGmG3/l8m7yTfBxA6MF4XEBIiuWZlPh/ILS6+adnAKcltuioSrdyaqZ09iccWDFk 5+aau1rkqlZy9vS3j0qYYfOaDj1dRTUFDtWfafD8Vzg4bwq9310edO38CFKSxJyBr+iT7SPsf 7PbrG2wLVelTzXCSpwM9I+j3m8Vk7vMY44kzpvuYVTCbUdEaIjY20FlIca5PKkGydZ0NE+p0d r8zY6+5nCGkw9DYJ14wj9j1wJkQ90v9yJBhxPQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This may be a somewhat controversial change, changing 64-bit architectures to use the same 'struct timespec64' definition that 32-bit architectures have, and removing a micro-optimization that tries to minimize the difference between timespec and timespec64. Starting with gcc-5, the compiler can completely optimize away the timespec_to_timespec64 and timespec64_to_timespec functions on 64-bit architectures. With older compilers, we introduce a couple of extra copies of local variables, but those are easily avoided by using the timespec64 based interfaces consistently, as we do in most of the important code paths already. The main upside of removing the hack is that printing the tv_sec field of a timespec64 structure can now use the %lld format string on all architectures without a cast to time64_t. Without this patch, the field is a 'long' type and would have to be printed using %ld on 64-bit architectures. Signed-off-by: Arnd Bergmann --- include/linux/time32.h | 18 +++-------------- include/linux/time64.h | 7 ------- include/linux/timekeeping32.h | 45 ------------------------------------------- kernel/time/time.c | 2 -- 4 files changed, 3 insertions(+), 69 deletions(-) -- 2.9.0 diff --git a/include/linux/time32.h b/include/linux/time32.h index 305f81dd5429..bd53e66bab1f 100644 --- a/include/linux/time32.h +++ b/include/linux/time32.h @@ -18,25 +18,14 @@ /* timespec64 is defined as timespec here */ static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) { - return ts64; + return *(const struct timespec *)&ts64; } static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) { - return ts; + return *(const struct timespec64 *)&ts; } -# define timespec_equal timespec64_equal -# define timespec_compare timespec64_compare -# define set_normalized_timespec set_normalized_timespec64 -# define timespec_add timespec64_add -# define timespec_sub timespec64_sub -# define timespec_valid timespec64_valid -# define timespec_valid_strict timespec64_valid_strict -# define timespec_to_ns timespec64_to_ns -# define ns_to_timespec ns_to_timespec64 -# define timespec_add_ns timespec64_add_ns - #else static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) { @@ -55,6 +44,7 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) ret.tv_nsec = ts.tv_nsec; return ret; } +#endif static inline int timespec_equal(const struct timespec *a, const struct timespec *b) @@ -157,8 +147,6 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns) a->tv_nsec = ns; } -#endif - /** * time_to_tm - converts the calendar time to local broken-down time * diff --git a/include/linux/time64.h b/include/linux/time64.h index ec1888cf5378..b6b5650d8fab 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -7,11 +7,6 @@ typedef __s64 time64_t; typedef __u64 timeu64_t; -#if __BITS_PER_LONG == 64 -/* this trick allows us to optimize out timespec64_to_timespec */ -# define timespec64 timespec -#define itimerspec64 itimerspec -#else struct timespec64 { time64_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ @@ -22,8 +17,6 @@ struct itimerspec64 { struct timespec64 it_value; }; -#endif - /* Parameters used to convert the timespec values: */ #define MSEC_PER_SEC 1000L #define USEC_PER_MSEC 1000L diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h index af4114d5dc17..f707ddb4dad7 100644 --- a/include/linux/timekeeping32.h +++ b/include/linux/timekeeping32.h @@ -19,50 +19,6 @@ static inline struct timespec current_kernel_time(void) return timespec64_to_timespec(now); } -#if BITS_PER_LONG == 64 -/** - * Deprecated. Use do_settimeofday64(). - */ -static inline int do_settimeofday(const struct timespec *ts) -{ - return do_settimeofday64(ts); -} - -static inline int __getnstimeofday(struct timespec *ts) -{ - return __getnstimeofday64(ts); -} - -static inline void getnstimeofday(struct timespec *ts) -{ - getnstimeofday64(ts); -} - -static inline void ktime_get_ts(struct timespec *ts) -{ - ktime_get_ts64(ts); -} - -static inline void ktime_get_real_ts(struct timespec *ts) -{ - getnstimeofday64(ts); -} - -static inline void getrawmonotonic(struct timespec *ts) -{ - getrawmonotonic64(ts); -} - -static inline struct timespec get_monotonic_coarse(void) -{ - return get_monotonic_coarse64(); -} - -static inline void getboottime(struct timespec *ts) -{ - return getboottime64(ts); -} -#else /** * Deprecated. Use do_settimeofday64(). */ @@ -127,7 +83,6 @@ static inline void getboottime(struct timespec *ts) getboottime64(&ts64); *ts = timespec64_to_timespec(ts64); } -#endif /* * Timespec interfaces utilizing the ktime based ones diff --git a/kernel/time/time.c b/kernel/time/time.c index fe60ebd301cf..4ad81b020c3e 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -407,7 +407,6 @@ time64_t mktime64(const unsigned int year0, const unsigned int mon0, } EXPORT_SYMBOL(mktime64); -#if __BITS_PER_LONG == 32 /** * set_normalized_timespec - set timespec sec and nsec parts and normalize * @@ -468,7 +467,6 @@ struct timespec ns_to_timespec(const s64 nsec) return ts; } EXPORT_SYMBOL(ns_to_timespec); -#endif /** * ns_to_timeval - Convert nanoseconds to timeval