[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.02.1309191207460.4089@ionos.tec.linutronix.de>
Date: Thu, 19 Sep 2013 12:15:10 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
cc: Ludovic Desroches <ludovic.desroches@...el.com>,
Russell King - ARM Linux <linux@....linux.org.uk>,
Marc Kleine-Budde <mkl@...gutronix.de>,
nicolas.ferre@...el.com, LKML <linux-kernel@...r.kernel.org>,
Marc Pignat <marc.pignat@...s.ch>, john.stultz@...aro.org,
kernel@...gutronix.de, Ronald Wahl <ronald.wahl@...itan.com>,
LAK <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] clockevents: Sanitize ticks to nsec conversion
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
Powered by blists - more mailing lists