All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Chris Metcalf <cmetcalf@mellanox.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	Prarit Bhargava <prarit@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <john.stultz@linaro.org>
Subject: [PATCH 4/4] timekeeping: clocksource_cyc2ns: Document intended range limitation
Date: Fri, 18 Nov 2016 20:50:14 -0800	[thread overview]
Message-ID: <1479531014-25264-5-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1479531014-25264-1-git-send-email-john.stultz@linaro.org>

From: Chris Metcalf <cmetcalf@mellanox.com>

The "cycles" argument should not be an absolute clocksource cycle
value, as the implementation's arithmetic will overflow relatively
easily with wide (64 bit) clocksource counters.

For performance, the implementation is simple and fast, since the
function is intended for only relatively small delta values of
clocksource cycles.

Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
[jstultz: Fixed up to merge against HEAD & commit message tweaks]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 include/linux/clocksource.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 0839818..0881bca 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -169,7 +169,10 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
  * @mult:	cycle to nanosecond multiplier
  * @shift:	cycle to nanosecond divisor (power of two)
  *
- * Converts cycles to nanoseconds, using the given mult and shift.
+ * Converts clocksource cycles to nanoseconds, using the given mult and shift.
+ * The code is optimized for performance and not intended to work
+ * with absolute clocksource cycles, as it will easily overflow,
+ * but just intended for relative (delta) clocksource cycles.
  *
  * XXX - This could use some mult_lxl_ll() asm optimization
  */
-- 
2.7.4

  parent reply	other threads:[~2016-11-19  4:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-19  4:50 [GIT PULL][PATCH 0/4] Timekeeping items for 4.10 John Stultz
2016-11-19  4:50 ` [PATCH 1/4] time: alarmtimer: Add the trcepoints for alarmtimer John Stultz
2016-11-21  8:13   ` Ingo Molnar
2016-11-21  8:46     ` Baolin Wang
2016-11-21  8:56       ` Thomas Gleixner
2016-11-21  9:02         ` Baolin Wang
2016-11-19  4:50 ` [PATCH 2/4] selftests/timers: Fix spelling mistake "Asyncrhonous" -> "Asynchronous" John Stultz
2016-11-19  4:50 ` [PATCH 3/4] timekeeping: Ignore the bogus sleep time if pm_trace is enabled John Stultz
2016-11-21  8:17   ` Ingo Molnar
2016-11-24  9:54     ` Chen, Yu C
2016-11-28 18:39       ` John Stultz
2016-11-28 23:45         ` Chen, Yu C
2016-11-19  4:50 ` John Stultz [this message]
2016-11-21  8:54   ` [PATCH 4/4] timekeeping: clocksource_cyc2ns: Document intended range limitation Ingo Molnar
2016-11-21 15:28     ` Chris Metcalf
2016-11-21 22:06       ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479531014-25264-5-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=cmetcalf@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.