From patchwork Fri Apr 27 13:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134620 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp738683lji; Fri, 27 Apr 2018 06:41:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq8bh/irkvW0Okepvn3qQwbwMXTH4e0OCkLw+bHthLygKcOzhoo3tXr+ByuAuO8T7Bi70pi X-Received: by 2002:a17:902:ea:: with SMTP id a97-v6mr2342548pla.28.1524836462976; Fri, 27 Apr 2018 06:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524836462; cv=none; d=google.com; s=arc-20160816; b=EiTAMARPUQvi3xOzLw6N1WgK7mWlspsybgVki5VGbz4nwBqrOjfOM47agJP8tpa8+l MRKz5DW5giWAay70xe1QamJhOY3PVnf2AHwCOnCzUoIFXiG7lk3XwtEv5GtuXxhivr88 gJo5TPF3H5E7zDJWpFNoQ8SEUjy+W5L9dX7PsrqOlAggbthWA1nFrwnTcUHtjSJOQKju LNRI5POXIOCe+TvcnxCd9baii0jKWWFWZZDQQKCP1Z6rMEElqOWEyZvTaxM4UuP+ZGjK ZC9SpBfDL2PZJkfI5cz+igtSVVS8lR0pXMpppeDyfJaThHJhbGFEaxhzFq5x++6YhtSD n2YQ== 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=AYRUoIgtq8ZOkdDiX5Zf3TJwP1FCKMWzD2ryuSCw/g4=; b=zDE22szEHvSw05Z4or24lqqDKB/qyXxoh3tLVpDQ2AYycTqNTyZBff+GR1qozjISu0 /cDAYEduh5/na/gzn5Dt0jovBgs5tf0lNqzuau2KR4LGDQ5AGH64fkEaymIxC/JvstEK 5mx4VFppilFu7n5RyzDqLIQ31YXLs8gv0TNewECI9khJ6ucA2FHm2gfX5Qu3577SUkyS UVKBCaY/pTAKLyQlW0Uu9rFCCz8e9sdD0xd8/K8MBvvo8soguR6q9JC9NcuW1yOuvGNo +NxMLPrIADnZIPffJd3et9ku9REPwM+6tugaSki0lw1jdf5SOnMK/kH/iIaOf24E8vsP mAGQ== 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 u186-v6si1270212pgc.67.2018.04.27.06.41.02; Fri, 27 Apr 2018 06:41:02 -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 S1758454AbeD0Nk7 (ORCPT + 29 others); Fri, 27 Apr 2018 09:40:59 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:47429 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932686AbeD0Nkc (ORCPT ); Fri, 27 Apr 2018 09:40:32 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Le9A8-1ebsOP1m04-00psGT; Fri, 27 Apr 2018 15:40:21 +0200 From: Arnd Bergmann To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Stephen Boyd , John Stultz , y2038@lists.linaro.org, Arnd Bergmann Subject: [PATCH 3/5] timekeeping: Standardize on ktime_get_*() naming Date: Fri, 27 Apr 2018 15:40:14 +0200 Message-Id: <20180427134016.2525989-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180427134016.2525989-1-arnd@arndb.de> References: <20180427134016.2525989-1-arnd@arndb.de> X-Provags-ID: V03:K1:l8yFmMGyxNrpnpcCuR0HaaKEo/1YgcJlEmIN48mbDRDQFmXKSd9 jDP3bnGRItMBHwS/lcVdv9o+Ii7vyAV1NfYsiyYbAK7bgCg4gOhcuxkBlyDef56a6P5JDTB C+v5v2I/bd50DEbmB1r/Y+V7TmASxqEeqOgstgF0w9NPt5e3O9JRbqXjWrD86xVcs1QtznJ Vrs/KRilqsJfDxLyd0grA== X-UI-Out-Filterresults: notjunk:1; V01:K0:HZOMufFobjQ=:IU8qrnDRTORZ9kG6rMJt61 LFDvMRJ+LR4KKraTD2VKYjNwE8yYydEBU1eW6vVq329yQzPtPuEaWNkgbSIoqQYiiQf1Dr1H0 cdiNzC+zBwt0OMhJsbMN93mVuRckr8rRixep+ISVv3a969HvqKmUYQG+dph1uH2HxGuLeTkr/ 7OvIzZctzOfFcXGi1gbOLV3EiyW7j79XWo74JelXoZXgZrXqBXuB8oLWLE6YtkKwqw1/xoFGV /Uk0flwX3pYabuu6iJ5DNf5qeoxi7OY7zundqNrgaOLQsF2A6a+zvICExK6uI3rTkjwM/wXT/ a9AiGqZzT7exDEYjbBcKSYCB4T9a0p/F4rE7W5YTyMhJ+hFmjTPoX/Hx1GdlAxiYM6xvNF0Wq XHREdMnKYOxYnwFWdGj/xaF19atlIrPWwXktmD8uuboKPZ80WUxOcuYT459GG3I6d122RieZO j9d1iFNrDxkUTDfavMbHB+ijzBfDDJFaJjmS63D7SKO9pD4p5N7Ql+pPABw5F9W8E5OpwwrOG bMJ8q05YY1Ms65w/wx8dHllSU7nNvHf3WtClg64CN/Zw5PgNzH9pTnO5+I//Pgntp5xG5F4Cu 5N78UADX7uJwSp9JOb08XwgZO++64W+/RwYa5FYLBUx+A2aNbTH0eES7SkrdJaLBJErUL8V1n xDt/3OqCyTXiCghVLps3erT5U61aw2+uvBj/tTuZ4Pdbrq4wU2A8A1WaqosVwLZbts4Q= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current_kernel_time64, get_monotonic_coarse64, getrawmonotonic64, get_monotonic_boottime64 and timekeeping_clocktai64 interfaces have rather inconsistent naming, and they differ in the calling conventions by passing the output either by reference or as a return value. Rename them to ktime_get_coarse_real_ts64, ktime_get_coarse_ts64, ktime_get_raw_ts64, ktime_get_boottime_ts64 and ktime_get_clocktai_ts64 respectively, and provide the interfaces with macros or inline functions as needed. Signed-off-by: Arnd Bergmann --- include/linux/timekeeping.h | 43 ++++++++++++++++++++++++++++++++----------- include/linux/timekeeping32.h | 14 ++++++++++---- kernel/time/timekeeping.c | 23 +++++++++-------------- 3 files changed, 51 insertions(+), 29 deletions(-) -- 2.9.0 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 415dae6bf1f5..3ef9791d7d75 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -19,25 +19,25 @@ extern void xtime_update(unsigned long ticks); extern int do_settimeofday64(const struct timespec64 *ts); extern int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz); -/* - * Kernel time accessors - */ -struct timespec64 current_kernel_time64(void); /* * timespec64 based interfaces */ -struct timespec64 get_monotonic_coarse64(void); -extern void getrawmonotonic64(struct timespec64 *ts); +extern void ktime_get_raw_ts64(struct timespec64 *ts); extern void ktime_get_ts64(struct timespec64 *ts); extern void ktime_get_real_ts64(struct timespec64 *tv); +extern void ktime_get_coarse_ts64(struct timespec64 *ts); +extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); + +void getboottime64(struct timespec64 *ts); + +/* + * time64_t base interfaces + */ extern time64_t ktime_get_seconds(void); extern time64_t __ktime_get_real_seconds(void); extern time64_t ktime_get_real_seconds(void); -extern void getboottime64(struct timespec64 *ts); - - /* * ktime_t based interfaces */ @@ -123,12 +123,12 @@ extern u64 ktime_get_real_fast_ns(void); /* * timespec64 interfaces utilizing the ktime based ones */ -static inline void get_monotonic_boottime64(struct timespec64 *ts) +static inline void ktime_get_boottime_ts64(struct timespec64 *ts) { *ts = ktime_to_timespec64(ktime_get_boottime()); } -static inline void timekeeping_clocktai64(struct timespec64 *ts) +static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) { *ts = ktime_to_timespec64(ktime_get_clocktai()); } @@ -212,5 +212,26 @@ extern int update_persistent_clock64(struct timespec64 now); * deprecated aliases, don't use in new code */ #define getnstimeofday64(ts) ktime_get_real_ts64(ts) +#define get_monotonic_boottime64(ts) ktime_get_boottime_ts64(ts) +#define getrawmonotonic64(ts) ktime_get_raw_ts64(ts) +#define timekeeping_clocktai64(ts) ktime_get_clocktai_ts64(ts) + +static inline struct timespec64 current_kernel_time64(void) +{ + struct timespec64 ts; + + ktime_get_coarse_real_ts64(&ts); + + return ts; +} + +static inline struct timespec64 get_monotonic_coarse64(void) +{ + struct timespec64 ts; + + ktime_get_coarse_ts64(&ts); + + return ts; +} #endif diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h index 5abff52d07fd..8762c2f45f8b 100644 --- a/include/linux/timekeeping32.h +++ b/include/linux/timekeeping32.h @@ -11,9 +11,11 @@ unsigned long get_seconds(void); static inline struct timespec current_kernel_time(void) { - struct timespec64 now = current_kernel_time64(); + struct timespec64 ts64; + + ktime_get_coarse_real_ts64(&ts64); - return timespec64_to_timespec(now); + return timespec64_to_timespec(ts64); } /** @@ -55,13 +57,17 @@ static inline void getrawmonotonic(struct timespec *ts) { struct timespec64 ts64; - getrawmonotonic64(&ts64); + ktime_get_raw_ts64(&ts64); *ts = timespec64_to_timespec(ts64); } static inline struct timespec get_monotonic_coarse(void) { - return timespec64_to_timespec(get_monotonic_coarse64()); + struct timespec64 ts64; + + ktime_get_coarse_ts64(&ts64); + + return timespec64_to_timespec(ts64); } static inline void getboottime(struct timespec *ts) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 7bbc7a6e6095..ed9b74ec9c0b 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1391,12 +1391,12 @@ int timekeeping_notify(struct clocksource *clock) } /** - * getrawmonotonic64 - Returns the raw monotonic time in a timespec + * ktime_get_raw_ts64 - Returns the raw monotonic time in a timespec * @ts: pointer to the timespec64 to be set * * Returns the raw monotonic time (completely un-modified by ntp) */ -void getrawmonotonic64(struct timespec64 *ts) +void ktime_get_raw_ts64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; unsigned long seq; @@ -1412,7 +1412,7 @@ void getrawmonotonic64(struct timespec64 *ts) ts->tv_nsec = 0; timespec64_add_ns(ts, nsecs); } -EXPORT_SYMBOL(getrawmonotonic64); +EXPORT_SYMBOL(ktime_get_raw_ts64); /** @@ -2114,23 +2114,20 @@ unsigned long get_seconds(void) } EXPORT_SYMBOL(get_seconds); -struct timespec64 current_kernel_time64(void) +void ktime_get_coarse_real_ts64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; - struct timespec64 now; unsigned long seq; do { seq = read_seqcount_begin(&tk_core.seq); - now = tk_xtime(tk); + *ts = tk_xtime(tk); } while (read_seqcount_retry(&tk_core.seq, seq)); - - return now; } -EXPORT_SYMBOL(current_kernel_time64); +EXPORT_SYMBOL(ktime_get_coarse_real_ts64); -struct timespec64 get_monotonic_coarse64(void) +void ktime_get_coarse_ts64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; struct timespec64 now, mono; @@ -2143,12 +2140,10 @@ struct timespec64 get_monotonic_coarse64(void) mono = tk->wall_to_monotonic; } while (read_seqcount_retry(&tk_core.seq, seq)); - set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, + set_normalized_timespec64(ts, now.tv_sec + mono.tv_sec, now.tv_nsec + mono.tv_nsec); - - return now; } -EXPORT_SYMBOL(get_monotonic_coarse64); +EXPORT_SYMBOL(ktime_get_coarse_ts64); /* * Must hold jiffies_lock