From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758013AbcGKIe4 (ORCPT ); Mon, 11 Jul 2016 04:34:56 -0400 Received: from www.linutronix.de ([62.245.132.108]:55793 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511AbcGKIez (ORCPT ); Mon, 11 Jul 2016 04:34:55 -0400 Date: Mon, 11 Jul 2016 10:32:04 +0200 (CEST) From: Thomas Gleixner To: Nicolai Stange cc: Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, John Stultz , Borislav Petkov , Paolo Bonzini , Viresh Kumar , Hidehiro Kawai , "Peter Zijlstra (Intel)" , "Christopher S. Hall" , Adrian Hunter , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/4] kernel/time/clockevents: compensate for monotonic clock's dynamic frequency In-Reply-To: <87inwcd6s7.fsf@gmail.com> Message-ID: References: <20160710193047.18320-1-nicstange@gmail.com> <20160710193047.18320-5-nicstange@gmail.com> <87inwcd6s7.fsf@gmail.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jul 2016, Nicolai Stange wrote: > > + raw = ((u64)interval >> 32) * raw_mult; /* Upper half of interval */ > > + if (raw >> 32) > > + return KTIME_MAX; > > + raw <<= 32; > > + tmp = ((u64)interval & U32_MAX) * raw_mult; /* Lower half of interval */ > > + if (U64_MAX - raw < tmp) > > + return KTIME_MAX; > > + raw += tmp; > > + > > + /* Finally, do raw /= mono_mult with proper rounding. */ > > + if (U64_MAX - raw < mono_mult / 2) > > + return KTIME_MAX; > > + raw += mono_mult / 2; > > + do_div(raw, mono_mult); > > + > > + return (s64)raw; That's a complete insanity. No way that we are going to do all this math in the CE programming path. If you want to address the issue, then you need to find a way to adjust the mult/shift factors of the clock event device occasionally. Thanks, tglx