From patchwork Sat Nov 19 04:50:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 83056 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp441386qge; Fri, 18 Nov 2016 20:50:26 -0800 (PST) X-Received: by 10.99.101.65 with SMTP id z62mr6965787pgb.74.1479531026706; Fri, 18 Nov 2016 20:50:26 -0800 (PST) Return-Path: Received: from mail-pg0-x22f.google.com (mail-pg0-x22f.google.com. [2607:f8b0:400e:c05::22f]) by mx.google.com with ESMTPS id t78si11333217pfj.273.2016.11.18.20.50.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Nov 2016 20:50:26 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22f as permitted sender) client-ip=2607:f8b0:400e:c05::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22f as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22f.google.com with SMTP id 3so109875763pgd.0 for ; Fri, 18 Nov 2016 20:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+8AoKIxx5rqltDPK770/gd6Q0P13bsqlt0B/SP101n0=; b=VHqc4l8Uflr16F5l0xBsWnxEdQTjSGTIFqkX07iKQCx77Z/5KdfRiuK96/XloiYveV woCjdBVehtuDqU2uZw27Z9fCzmBOwCwmZqldHxsIqliW5ERGdFyIbRXAI/TQAD7snfxG YCeutSTxiEyuB8x/b3Mh9f1703lBaxQfMP15U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+8AoKIxx5rqltDPK770/gd6Q0P13bsqlt0B/SP101n0=; b=Tc3BCdnX1meBGurBoc5fKyuWxCCFgXaftb4RdyPKA+f8sHzXZRxhaGc/+LdG5K2fPW NrH8R/UYRzD+SSM+QiCuV2Wn25T9o4xLcHZ3X56uxsQ+PgoK9aM/etUA33dbcPh2P+By EQ8hSddkIUadNACh+Jve23xSkwIxEjfIfcBd883G1NjFJpjapsYYLoiZaT7MRU/t1Q7p Yqz+eabHcsasHmCHiOy2qCvd1rukHpdog7grqt9nnEq8Mc+BhYOD/x1At8/qUHi6u66P Ro47Cp2dLpa234yJU8t8Hhjg3ktOyNMnIc6qEcYxr6CRqOUESbZRX8E4/1m17RY5hE13 UcZQ== X-Gm-Message-State: AKaTC00f72cv0W5JJR0bU7eBcdwzz82KbfGhnw38lM/a1l/pCY1qV8NGLyWxOxmLM4kgEgq2qf4= X-Received: by 10.98.149.140 with SMTP id c12mr4191395pfk.100.1479531026424; Fri, 18 Nov 2016 20:50:26 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id w17sm3292973pgm.18.2016.11.18.20.50.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Nov 2016 20:50:26 -0800 (PST) From: John Stultz To: lkml Cc: Chris Metcalf , Richard Cochran , Ingo Molnar , Prarit Bhargava , Thomas Gleixner , John Stultz Subject: [PATCH 4/4] timekeeping: clocksource_cyc2ns: Document intended range limitation Date: Fri, 18 Nov 2016 20:50:14 -0800 Message-Id: <1479531014-25264-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479531014-25264-1-git-send-email-john.stultz@linaro.org> References: <1479531014-25264-1-git-send-email-john.stultz@linaro.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] Signed-off-by: John Stultz --- include/linux/clocksource.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.7.4 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 */