Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753564Ab3ISKPS (ORCPT ); Thu, 19 Sep 2013 06:15:18 -0400 Received: from www.linutronix.de ([62.245.132.108]:35130 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348Ab3ISKPQ (ORCPT ); Thu, 19 Sep 2013 06:15:16 -0400 Date: Thu, 19 Sep 2013 12:15:10 +0200 (CEST) From: Thomas Gleixner To: =?ISO-8859-15?Q?Uwe_Kleine-K=F6nig?= cc: Ludovic Desroches , Russell King - ARM Linux , Marc Kleine-Budde , nicolas.ferre@atmel.com, LKML , Marc Pignat , john.stultz@linaro.org, kernel@pengutronix.de, Ronald Wahl , LAK Subject: Re: [PATCH] clockevents: Sanitize ticks to nsec conversion In-Reply-To: <20130919100239.GS24802@pengutronix.de> Message-ID: References: <1379077365-18458-1-git-send-email-mkl@pengutronix.de> <20130917095600.GJ26819@ludovic.desroches@atmel.com> <20130917100417.GQ12758@n2100.arm.linux.org.uk> <20130917130153.GL26819@ludovic.desroches@atmel.com> <20130918085627.GN24802@pengutronix.de> <20130918150958.GO24802@pengutronix.de> <20130919100239.GS24802@pengutronix.de> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-2021595928-1379585711=:4089" 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 Content-Length: 1508 Lines: 41 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2021595928-1379585711=:4089 Content-Type: TEXT/PLAIN; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT On Thu, 19 Sep 2013, Uwe Kleine-K?nig wrote: > On Thu, Sep 19, 2013 at 12:01:25AM +0200, Thomas Gleixner wrote: > > Versus the 64bit overflow check, we need to be even more careful. We > > need to check for overflowing (1 << 63) - 1 (i.e. the max positive > > value which fits into a s64). See clockevents_program_event(). > > That is because you interpret times < 0 as in the past, right? But note > that the interim result we're talking about here is still to be divided > by evt->mult. So assuming mult > 1, that check is too strict unless you > move it below the do_div in clockevent_delta2ns. For sure it makes sense > to use the same value for a and b in the handling: No, it's not too strict. nsec = (latch << shift) / mult; Now the backwards conversion does: latch = (nsec * mult) >> shift; So we want nsec * mult to be in the positive range of s64. Which means, that latch << shift must be in that range as well. Thanks, tglx --8323329-2021595928-1379585711=:4089-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/