[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.11.1412031525320.470@knanqh.ubzr>
Date: Wed, 3 Dec 2014 15:37:39 -0500 (EST)
From: Nicolas Pitre <nicolas.pitre@...aro.org>
To: Robert Jarzmik <robert.jarzmik@...e.fr>
cc: Thomas Gleixner <tglx@...utronix.de>,
John Stultz <john.stultz@...aro.org>,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] optimize ktime_divns for constant divisors
On Wed, 3 Dec 2014, Robert Jarzmik wrote:
> Nicolas Pitre <nicolas.pitre@...aro.org> writes:
>
> > Let ktime_divns() use do_div() inline whenever the divisor is constant
> > and small enough. This will make things like ktime_to_us() and
> > ktime_to_ms() much faster.
>
> Hi Nicolas,
>
> I suppose the "small enough" is linked to the "!(div >> 32)" in your patch. Can
> I have the rationale which brought up this value, and if that value is universal
> across architectures (ie. x86/ppc/arm/...) ?
Yes. The do_div() function is defined to accept a 32-bit divisor only.
The out-of-line ktime_divns code does scale down both the dividend and
the divisor until the divisor is within 32 bits of magnitude before
calling do_div(). However the constness of the divisor is lost and the
optimised do_div (on ARM at least) doesn't get involved.
> And when you say "much faster", do you have figures to add to your commit
> message ?
No actual figure. But a wild guess would be around an order of
magnitude. See commit fa4adc6149 for an example of generated code.
Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists