From patchwork Mon Nov 28 22:35:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 84464 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1348532qgi; Mon, 28 Nov 2016 14:35:30 -0800 (PST) X-Received: by 10.84.149.139 with SMTP id m11mr54592631pla.38.1480372530706; Mon, 28 Nov 2016 14:35:30 -0800 (PST) Return-Path: Received: from mail-pg0-x229.google.com (mail-pg0-x229.google.com. [2607:f8b0:400e:c05::229]) by mx.google.com with ESMTPS id h5si52881002pgg.22.2016.11.28.14.35.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 14:35:30 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::229 as permitted sender) client-ip=2607:f8b0:400e:c05::229; 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::229 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x229.google.com with SMTP id 3so61541146pgd.0 for ; Mon, 28 Nov 2016 14:35:30 -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=ydYW7DPQ7nMYwnA/jOfoY/YuL7SMFLtlGFVEgYlEWl4=; b=K+Nt8ZwE3bgDH87QGgKnDBxMNH5U/93mvb2BkZzWizZnPoIba8lv46sg8QYIU3Os24 PcXL8Ef0jZHrUMIvpC9jAie+DirSyOo4p46Lju6I1lNEdZvOZAD5a+xf1qDKOqiUmqD3 f8xaMrf+RbUmZ6g+AbTfZGEF6jorqkSaRl3hQ= 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=ydYW7DPQ7nMYwnA/jOfoY/YuL7SMFLtlGFVEgYlEWl4=; b=gCcoDu/lV1PKUnbEjqJJ+gjC+HMBIrOX5cYWQrMi51RSAXt0Q+A7BqEB85SKR6JfUY g9f7mLxrRxrPA6rwWcsTDnAjtOkDBJ4kIY4mHDP67Ee7hCN4t2Nxj0fUsBstXsnXV4ve HgscMKRSXwwm0wn5bEJZSRpGHrM58fVrL0f45opbMFyUcxQyKe1/9lBqBUduxuK6ttFb Ug6o9NnYiK+uTbe64BsFkxr1xz6kjs0Ubx/7wISZ9j2+8adYqYjyf2Lg2gzCanaiWfRO 3CAbzzkl2/rafaWyH+er9U3QEr+WYR0Ep7JPl6wE43rPg649mMzV8O+ozLscGCzHBSy9 xOfw== X-Gm-Message-State: AKaTC01FeNsV40xly26gtEFKFTdaVedsYuGM3aSSSMJtwCRnyhdI/wgse8GwscZJ9AQqKslEmpI= X-Received: by 10.99.219.21 with SMTP id e21mr43500097pgg.136.1480372530416; Mon, 28 Nov 2016 14:35:30 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id r74sm89537352pfl.79.2016.11.28.14.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 14:35:29 -0800 (PST) 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> 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(-) -- 2.7.4 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 */