From patchwork Thu Jun 20 14:11:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 167341 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2124628ilk; Thu, 20 Jun 2019 07:12:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFY4bEXjsT7fW47mQHmpS/7WWAuW115+6Hk5hOB81OzprgvoiL2yAPxcEPO9yuaWyXm4c0 X-Received: by 2002:a62:1ec1:: with SMTP id e184mr40082245pfe.185.1561039949369; Thu, 20 Jun 2019 07:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561039949; cv=none; d=google.com; s=arc-20160816; b=jQN6LeM9uWFbFZ7GAw/ghNaKf9YZaAV6XDiPL6Nqb1jAW3xf4yCev581zHPXxwa5wd VoUnLC7EJ+AQldaMMeLieUd9GE8uO8yOtHFLOOtsxEq/+ETfDmhhK4zBiKr2ouVB4wRO rgDx9gYnJPFB/x41oTVHBmTuOLF/Hg9u0eVVwknVG8yoRDcian9NHQDo6VU247shBYGN H6kGqkCMZyITVJ7lHBor4XYRSbuEqKpAR0K+LYTyec8kLfBNgOY0Z8qum0/d5hX1ifUh LhbgsYDWffQHGzJav1o3v7b3bMmssaQM3ORHPFcVK7kAq1s88F9JsI7mRYa5vNgAWBpr 8Jpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=evihxJu+CY5ZOHsghLHEJmh2CDiIYzmATMtmRPeJCx4=; b=qiI8cCIaamy9nGEVqvnncLF1TCwNHuAmTDAB36LlK3O70jeOjzepgJ375M3imlPIgo /6xCqUzTj6GR0Dabive+qPVH1TH0Vdb/e3f4apbNvEoZzB6kqdZ3v1HQbx4gL3oo7+yF ZqdtVyoCxB/VQ9w6Vlz0dWduxvZR+7UYLWKzImCcC34YKL9bgVR2CxWz3cVh87JNLPgg n/Ob5q0MSKuamybKMgrMbIS1a6oM+sME4tes77hlcXOE56qL9QXLJQIrWv113jlaLv4v sAcfjYkw9MupDCQbIPoVyxpJDjfc4705Jj1x1LqykkIpVvbCicoebZfcMq9Hw2rq8IZ2 moFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=ekC0cJXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si5803161pgp.332.2019.06.20.07.12.29; Thu, 20 Jun 2019 07:12:29 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=ekC0cJXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732093AbfFTOM1 (ORCPT + 30 others); Thu, 20 Jun 2019 10:12:27 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46513 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfFTOM1 (ORCPT ); Thu, 20 Jun 2019 10:12:27 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 67cf0242; Thu, 20 Jun 2019 13:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=AQ6Tdsbdfrjdj08fQbWcxJCHd WM=; b=ekC0cJXDi8IgYRbkyJDDDOnkdmxA5JwHCSHDBrlwxPu8vBZJZZNljPopb fYXeGmnEF4IZt4ujrPEGkLSElCKGeIRRBQDA9OUz26nbSYCQl032/y60vWDvJcv/ BBbrGhQIfKkVXzdufY8EuBrieHgZE8jFFCdyTmHBDPv2HaqgPVnRiyAYOISI6aAz DGvTP0Ys51zkO8S/Yrr1KN2O0ZR2RZQ44Sz2VnOoAP1e84oL0iPiZxg2X3ED6L+w yKH2LXyv8PJNTtZFWD2m+N0qkPDQVMQA/gKks0BkPEWIU5kvwemJ/Tbz/Q21GzXj XvFJ7ajSc3lcbz0y9NM4MPIpnszEQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2c15e23e (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Thu, 20 Jun 2019 13:39:09 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH 1/3] timekeeping: add missing non-_ns functions for fast accessors Date: Thu, 20 Jun 2019 16:11:57 +0200 Message-Id: <20190620141159.15965-1-Jason@zx2c4.com> In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously there was no analogue to get proper ktime_t versions of the fast variety of ktime invocations. This commit makes the interface uniform with the other accessors. Signed-off-by: Jason A. Donenfeld Cc: Arnd Bergmann Cc: Thomas Gleixner --- Documentation/core-api/timekeeping.rst | 7 +++- include/linux/timekeeping.h | 28 ++++++++++++-- kernel/time/timekeeping.c | 52 +++++++++++++------------- 3 files changed, 55 insertions(+), 32 deletions(-) -- 2.21.0 diff --git a/Documentation/core-api/timekeeping.rst b/Documentation/core-api/timekeeping.rst index 93cbeb9daec0..ad32085174f8 100644 --- a/Documentation/core-api/timekeeping.rst +++ b/Documentation/core-api/timekeeping.rst @@ -94,7 +94,7 @@ different format depending on what is required by the user: down the seconds to the full seconds of the last timer tick using the respective reference. -Coarse and fast_ns access +Coarse and fast access ------------------------- Some additional variants exist for more specialized cases: @@ -125,6 +125,11 @@ Some additional variants exist for more specialized cases: up to several microseconds on older hardware with an external clocksource. +.. c:function:: ktime_t ktime_get_mono_fast_ns( void ) + ktime_t ktime_get_raw_fast_ns( void ) + ktime_t ktime_get_boottime_fast_ns( void ) + ktime_t ktime_get_real_fast_ns( void ) + .. c:function:: u64 ktime_get_mono_fast_ns( void ) u64 ktime_get_raw_fast_ns( void ) u64 ktime_get_boot_fast_ns( void ) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index a8ab0f143ac4..c5d360779fab 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -146,10 +146,30 @@ static inline u64 ktime_get_raw_ns(void) return ktime_to_ns(ktime_get_raw()); } -extern u64 ktime_get_mono_fast_ns(void); -extern u64 ktime_get_raw_fast_ns(void); -extern u64 ktime_get_boot_fast_ns(void); -extern u64 ktime_get_real_fast_ns(void); +extern ktime_t ktime_get_mono_fast(void); +extern ktime_t ktime_get_raw_fast(void); +extern ktime_t ktime_get_boottime_fast(void); +extern ktime_t ktime_get_real_fast(void); + +static inline u64 ktime_get_mono_fast_ns(void) +{ + return ktime_to_ns(ktime_get_mono_fast()); +} + +static inline u64 ktime_get_raw_fast_ns(void) +{ + return ktime_to_ns(ktime_get_raw_fast()); +} + +static inline u64 ktime_get_boot_fast_ns(void) +{ + return ktime_to_ns(ktime_get_boottime_fast()); +} + +static inline u64 ktime_get_real_fast_ns(void) +{ + return ktime_to_ns(ktime_get_real_fast()); +} /* * timespec64/time64_t interfaces utilizing the ktime based ones diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 44b726bab4bd..4c97c9c8c217 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -443,41 +443,40 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr, * of the following timestamps. Callers need to be aware of that and * deal with it. */ -static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) +static __always_inline ktime_t __ktime_get_fast(struct tk_fast *tkf) { struct tk_read_base *tkr; unsigned int seq; - u64 now; + ktime_t now; do { seq = raw_read_seqcount_latch(&tkf->seq); tkr = tkf->base + (seq & 0x01); - now = ktime_to_ns(tkr->base); - - now += timekeeping_delta_to_ns(tkr, + now = ktime_add_ns(tkr->base, + timekeeping_delta_to_ns(tkr, clocksource_delta( tk_clock_read(tkr), tkr->cycle_last, - tkr->mask)); + tkr->mask))); } while (read_seqcount_retry(&tkf->seq, seq)); return now; } -u64 ktime_get_mono_fast_ns(void) +ktime_t ktime_get_mono_fast(void) { - return __ktime_get_fast_ns(&tk_fast_mono); + return __ktime_get_fast(&tk_fast_mono); } -EXPORT_SYMBOL_GPL(ktime_get_mono_fast_ns); +EXPORT_SYMBOL_GPL(ktime_get_mono_fast); -u64 ktime_get_raw_fast_ns(void) +ktime_t ktime_get_raw_fast(void) { - return __ktime_get_fast_ns(&tk_fast_raw); + return __ktime_get_fast(&tk_fast_raw); } -EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns); +EXPORT_SYMBOL_GPL(ktime_get_raw_fast); /** - * ktime_get_boot_fast_ns - NMI safe and fast access to boot clock. + * ktime_get_boottime_fast - NMI safe and fast access to boot clock. * * To keep it NMI safe since we're accessing from tracing, we're not using a * separate timekeeper with updates to monotonic clock and boot offset @@ -497,47 +496,46 @@ EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns); * partially updated. Since the tk->offs_boot update is a rare event, this * should be a rare occurrence which postprocessing should be able to handle. */ -u64 notrace ktime_get_boot_fast_ns(void) +ktime_t notrace ktime_get_boottime_fast(void) { struct timekeeper *tk = &tk_core.timekeeper; - return (ktime_get_mono_fast_ns() + ktime_to_ns(tk->offs_boot)); + return ktime_add(ktime_get_mono_fast(), tk->offs_boot); } -EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns); +EXPORT_SYMBOL_GPL(ktime_get_boottime_fast); /* - * See comment for __ktime_get_fast_ns() vs. timestamp ordering + * See comment for __ktime_get_fast() vs. timestamp ordering */ -static __always_inline u64 __ktime_get_real_fast_ns(struct tk_fast *tkf) +static __always_inline ktime_t __ktime_get_real_fast(struct tk_fast *tkf) { struct tk_read_base *tkr; unsigned int seq; - u64 now; + ktime_t now; do { seq = raw_read_seqcount_latch(&tkf->seq); tkr = tkf->base + (seq & 0x01); - now = ktime_to_ns(tkr->base_real); - - now += timekeeping_delta_to_ns(tkr, + now = ktime_add_ns(tkr->base_real, + timekeeping_delta_to_ns(tkr, clocksource_delta( tk_clock_read(tkr), tkr->cycle_last, - tkr->mask)); + tkr->mask))); } while (read_seqcount_retry(&tkf->seq, seq)); return now; } /** - * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime. + * ktime_get_real_fast: - NMI safe and fast access to clock realtime. */ -u64 ktime_get_real_fast_ns(void) +ktime_t ktime_get_real_fast(void) { - return __ktime_get_real_fast_ns(&tk_fast_mono); + return __ktime_get_real_fast(&tk_fast_mono); } -EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns); +EXPORT_SYMBOL_GPL(ktime_get_real_fast); /** * halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource. From patchwork Thu Jun 20 14:11:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 167342 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2124706ilk; Thu, 20 Jun 2019 07:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGcQ+5/SFc4rebTBdA5vRaj0BOXvnp95oB/iHN/2E9qQDasT+t0b9zYh8PHFbHKPtEuSb+ X-Received: by 2002:a65:64d6:: with SMTP id t22mr13358854pgv.406.1561039953627; Thu, 20 Jun 2019 07:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561039953; cv=none; d=google.com; s=arc-20160816; b=BE1AKEEayWnOdbghPpaEr2Mtk1Q/TDIIFyEcwk6TDc6ObZlwddEFc1ul6VwfncipYi yRC74/a9as113Efxu1BN171gxWkymrsXXhbp+sL10Hr2Dx+O7jofYRx9YPd5G0xpX87A 0MiYpdLxQeJL7NYuUqdyuLuS1nCuEEoR04FkR0C0IILBVI90PzZvVhYve1MztELPq/Ra wfe+5lCf7XaU+IRlQXXag6mGjVzLNd/tvOcoJbEw5yAyzcq3A0uqX7CRy81BqtprxCFy DpJPAYWhRiF27LVRJKTfJiJTR8U0Ma6HccGB2noVu+dIoDXjmXgWhLh/yTVsBKXmxi4c pM/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YNli0qn/fXNhKtDOdCT3+KRB+1OZlplDHTQ2SaEZ0wA=; b=o20CYmAunuo1OxacVdpl92hKuM/dC9ZyCjB6PIDwqtSCPhJUTpSb9Xx88jWzozVe9w AIYTve8PrjTmp7/iq9RueAO0O1su6bffxToXQ6Jgf0ph6aT3ebsaUofU1/nbjTl3vRSh z8+H6R0N4KP8nDHu9Axv433CLlWqExAvd9YMtQ0YEB4KoALW8ac3QNz36MkTjUAGUyn3 uBrXsfg7ri5bNiUKWNu6vU/C0snoRya0DtkkiQblzPECcG+csqgMPnjCec+x6xpaL7fK BNR6oKZgCmyuEbqNhNU1xVKFGEf1hKMDCb4bTPPfRXwxBml+BQ+7MDNJgYHimw+VVXXF Wi1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=GB2hYv37; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h32si7818170pld.402.2019.06.20.07.12.33; Thu, 20 Jun 2019 07:12:33 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=GB2hYv37; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732164AbfFTOMb (ORCPT + 30 others); Thu, 20 Jun 2019 10:12:31 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46513 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbfFTOMa (ORCPT ); Thu, 20 Jun 2019 10:12:30 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 6070bff6; Thu, 20 Jun 2019 13:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=59+R4/Fx/t8SyqprWAb/cnYmq hU=; b=GB2hYv37Ue9iey2fY1DbB5LsOHqqz0ANLpJt42JcEZSVrEwehdSKuLPJg FWrKqI4tPX7/Is8WAMF6inDpNj4JIphdUl9hynwbwcLk+rSLuDqO6qCayt/n0/kA HFt+tZgVK5qRCTLzzk8+f2fa0h/6/5QBCG77gjaQVynyuo3rlzB8SzJv431MDUUv DrsQhfNWcliCGJo6loT4O9PD+vwSvsoVQkBJhJ1OiJ/uYOfYNTaQgvTfDnoDZMII u+3jyEVz8awx400YNIMtg5Ov51sril7HNcrnYhMDwaN0/lulvdU5V9pLOhD7cfB3 +0+Xx0HQVrrONA5yS8Wt4EHhT0b8w== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ec5a4d62 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Thu, 20 Jun 2019 13:39:11 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH 2/3] timekeeping: use proper ktime_add when adding nsecs in coarse offset Date: Thu, 20 Jun 2019 16:11:58 +0200 Message-Id: <20190620141159.15965-2-Jason@zx2c4.com> In-Reply-To: <20190620141159.15965-1-Jason@zx2c4.com> References: <20190620141159.15965-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While this doesn't actually amount to a real difference, since the macro evaluates to the same thing, every place else operates on ktime_t using these functions, so let's not break the pattern. Fixes: e3ff9c3678b4 ("timekeeping: Repair ktime_get_coarse*() granularity") Signed-off-by: Jason A. Donenfeld Cc: Arnd Bergmann Cc: Thomas Gleixner --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 Acked-by: Arnd Bergmann diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4c97c9c8c217..db0081a14b90 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -817,7 +817,7 @@ ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs) } while (read_seqcount_retry(&tk_core.seq, seq)); - return base + nsecs; + return ktime_add_ns(base, nsecs); } EXPORT_SYMBOL_GPL(ktime_get_coarse_with_offset); From patchwork Thu Jun 20 14:11:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 167343 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2124756ilk; Thu, 20 Jun 2019 07:12:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlvOhA4Wv9sDZpw16pQloxZJjxxkvf0SKvKq98uGmgMF7fRqrBC9vBCK5TKmvjKzROoXRT X-Received: by 2002:a17:90a:216f:: with SMTP id a102mr3401739pje.29.1561039956044; Thu, 20 Jun 2019 07:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561039956; cv=none; d=google.com; s=arc-20160816; b=KEC9f3OArYY3L/ZKzv8E+YUpjcm0kjNq/ZdWVTsfoFIbVcyZ9kK4FbAROJfqdotWqY hKONOvc3ef6qurFj5vFPvTcWdJgSewHhXSA7NhGScZDT/kj9m9otqivvWC63XDPdEJMj cdNMa2Pye26yaXxP514344d4inbQOZMCD/XFt9mtbIIJlpbZqFsfDZ5188oPKpgu6r0s ClO6J6GQL176PylMXjfZ7hoWL6a3oC1zY2i1eViwzTNnEbc7G6Gn4Ttb60lOYWcP0TAu K1UTGSod0k4wPLe/aWpg1j1Qo184ucUoE8oBqDOIxqrNiXEp5WM666Q13PKVwDQPD1WV JOcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JDegmG5uFKjJ8c8yxdYHWZtZl88yh+8bzXvRnfmlCro=; b=QCUFOc0OwBL9LTzlYAF7Yaf0FQCnD/ESbRToQC60wDo0tAznPPucy6gaWBCUHU7EvW 8ZdoeepzLHy4RMkmsJqw3u8klTcRZapMdRutROJ0z//U4m71bk7NVvc5aEL7SZyIdd2F hX+dHZ7YnNHnYwBPAfCRfr5gtimaqHdQFgo3eSU46IPHxhHXSjEsKVApJBRd3ysEp/Kw Pn5SaL4qPUG9dZO//COkFI9hxW/JpYH8jEORyDe73kuPIxJWcUNxulV3SyXIxJ4GC/l3 2m836SzOezKRiEt1SBtbn+QdnR0XafSJ1e2tGftXBu6i0HcTNwiLUDS4ACvXAYTUhjcV CSuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=hbhNRQit; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24si5754638pgv.242.2019.06.20.07.12.35; Thu, 20 Jun 2019 07:12:36 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=hbhNRQit; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732172AbfFTOMe (ORCPT + 30 others); Thu, 20 Jun 2019 10:12:34 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46513 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfFTOMb (ORCPT ); Thu, 20 Jun 2019 10:12:31 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id c9fd27a9; Thu, 20 Jun 2019 13:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=0Fdw7HaeEiZuqMq3Bs3OcHBPs N0=; b=hbhNRQitEi35VPDhVdSARikBsNjSpCOZKRHHkg/49LlfcVyv8LE14FOzU ChmQ8BRHTOOyigdk/yC8uOBmd0EhyF9a+duR4yMv+c6mA59r1FaZWw1iDJ+9/+Fl KZthbGFb6PC32d4B/AG0ZW4jDN7cEwLNTQ9gL8G/YGFDtavPRsM6JEoUdtSVDL0Q hmKsb/s2VmllMwc3D1t1SCE5YMlHSy2uJCGw5uFJIOViXWGB/Z7KfyiPccJ/mAHh yaHHbZh6JYEyb0QtvjHLPW/V/cUczO8kQzh9Yt0fTea+qYJJc0gO3G7KeX1X/D8c 185/RebJKwBYvfdeXsnyrpkOW+WYQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2e56fd00 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Thu, 20 Jun 2019 13:39:13 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH 3/3] timekeeping: add missing _ns functions for coarse accessors Date: Thu, 20 Jun 2019 16:11:59 +0200 Message-Id: <20190620141159.15965-3-Jason@zx2c4.com> In-Reply-To: <20190620141159.15965-1-Jason@zx2c4.com> References: <20190620141159.15965-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This further unifies the accessors for the fast and coarse functions, so that the same types of functions are available for each. There was also a bit of confusion with the documentation, which prior advertised a function that has never existed. Finally, the vanilla ktime_get_coarse() was omitted from the API originally, so this fills this oversight. Signed-off-by: Jason A. Donenfeld Cc: Arnd Bergmann Cc: Thomas Gleixner --- Documentation/core-api/timekeeping.rst | 10 +++++++--- include/linux/timekeeping.h | 27 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/Documentation/core-api/timekeeping.rst b/Documentation/core-api/timekeeping.rst index ad32085174f8..d5e88f0e06a4 100644 --- a/Documentation/core-api/timekeeping.rst +++ b/Documentation/core-api/timekeeping.rst @@ -99,16 +99,20 @@ Coarse and fast access Some additional variants exist for more specialized cases: -.. c:function:: ktime_t ktime_get_coarse_boottime( void ) +.. c:function:: ktime_t ktime_get_coarse( void ) + ktime_t ktime_get_coarse_boottime( void ) ktime_t ktime_get_coarse_real( void ) ktime_t ktime_get_coarse_clocktai( void ) - ktime_t ktime_get_coarse_raw( void ) + +.. c:function:: u64 ktime_get_coarse_ns( void ) + u64 ktime_get_boot_coarse_ns( void ) + u64 ktime_get_real_coarse_ns( void ) + u64 ktime_get_tai_coarse_ns( void ) .. c:function:: void ktime_get_coarse_ts64( struct timespec64 * ) void ktime_get_coarse_boottime_ts64( struct timespec64 * ) void ktime_get_coarse_real_ts64( struct timespec64 * ) void ktime_get_coarse_clocktai_ts64( struct timespec64 * ) - void ktime_get_coarse_raw_ts64( struct timespec64 * ) These are quicker than the non-coarse versions, but less accurate, corresponding to CLOCK_MONONOTNIC_COARSE and CLOCK_REALTIME_COARSE diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index c5d360779fab..3df8e63c704b 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -113,6 +113,33 @@ static inline ktime_t ktime_get_coarse_clocktai(void) return ktime_get_coarse_with_offset(TK_OFFS_TAI); } +static inline ktime_t ktime_get_coarse(void) +{ + struct timespec64 ts; + ktime_get_coarse_ts64(&ts); + return timespec64_to_ktime(ts); +} + +static inline u64 ktime_get_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse()); +} + +static inline u64 ktime_get_real_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_real()); +} + +static inline u64 ktime_get_boot_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_boottime()); +} + +static inline u64 ktime_get_tai_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_clocktai()); +} + /** * ktime_mono_to_real - Convert monotonic time to clock realtime */