From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753994AbcKPTfn (ORCPT ); Wed, 16 Nov 2016 14:35:43 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54795 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752517AbcKPTfl (ORCPT ); Wed, 16 Nov 2016 14:35:41 -0500 From: Chris Metcalf To: John Stultz , Thomas Gleixner , Salman Qazi , Paul Turner , Tony Lindgren , Steven Miao , linux-kernel@vger.kernel.org Cc: Chris Metcalf Subject: [PATCH v2] tile: avoid using clocksource_cyc2ns with absolute cycle count Date: Wed, 16 Nov 2016 14:35:33 -0500 Message-Id: <1479324933-8161-1-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For large values of "mult" and long uptimes, the intermediate result of "cycles * mult" can overflow 64 bits. For example, the tile platform calls clocksource_cyc2ns with a 1.2 GHz clock; we have mult = 853, and after 208.5 days, we overflow 64 bits. Since clocksource_cyc2ns() is intended to be used for relative cycle counts, not absolute cycle counts, performance is more importance than accepting a wider range of cycle values. So, just use mult_frac() directly in tile's sched_clock(). Signed-off-by: Chris Metcalf --- Blackfin should make a similar change in their sched_clock(). arch/tile/kernel/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c index 178989e6d3e3..ea960d660917 100644 --- a/arch/tile/kernel/time.c +++ b/arch/tile/kernel/time.c @@ -218,8 +218,8 @@ void do_timer_interrupt(struct pt_regs *regs, int fault_num) */ unsigned long long sched_clock(void) { - return clocksource_cyc2ns(get_cycles(), - sched_clock_mult, SCHED_CLOCK_SHIFT); + return mult_frac(get_cycles(), + sched_clock_mult, 1ULL << SCHED_CLOCK_SHIFT); } int setup_profiling_timer(unsigned int multiplier) -- 2.7.2