From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932631AbcK1WgA (ORCPT ); Mon, 28 Nov 2016 17:36:00 -0500 Received: from mail-pg0-f44.google.com ([74.125.83.44]:36580 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755612AbcK1Wfc (ORCPT ); Mon, 28 Nov 2016 17:35:32 -0500 From: John Stultz To: lkml Cc: Chris Metcalf , Richard Cochran , Ingo Molnar , Prarit Bhargava , Thomas Gleixner , John Stultz Subject: [PATCH 3/7] timekeeping: clocksource_cyc2ns: Document intended range limitation Date: Mon, 28 Nov 2016 14:35:20 -0800 Message-Id: <1480372524-15181-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480372524-15181-1-git-send-email-john.stultz@linaro.org> References: <1480372524-15181-1-git-send-email-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Metcalf 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 Cc: Ingo Molnar Cc: Prarit Bhargava Cc: Thomas Gleixner Signed-off-by: Chris Metcalf [jstultz: Fixed up to merge against HEAD & commit message tweaks, also included rewording suggestion by Ingo] Signed-off-by: John Stultz --- v2: Reworded comments as suggested by Ingo --- 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..65602d3 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 is not intended to work + * with absolute clocksource cycles (as those will easily overflow), + * but is only intended to be used with relative (delta) clocksource cycles. * * XXX - This could use some mult_lxl_ll() asm optimization */ -- 2.7.4