Re: [PATCH v2] ktime: Simplify ktime_compare implementation

From: Thomas Gleixner
Date: Mon Jun 26 2017 - 04:45:43 EST


On Mon, 26 Jun 2017, Thierry Reding wrote:
> On Fri, May 26, 2017 at 03:00:47PM +0200, Mariusz Skamra wrote:
> > ktime_sub can be used here instread of two conditional checks.
>
> Boot is broken on Tegra186 on next-20170623. Bisection points at this
> commit and I've confirmed that reverting it also fixes the problem.
>
> Another fix is to change the return value of ktime_compare() to ktime_t,
> though I'm not sure that'd be a good alternative because it breaks with
> the traditional return type of int (-1, 0, +1) for comparison functions.
>
> It looks like the issue is with the truncation from s64 to int, as
> demonstrated by this minimal test case:

You are right. And I should have seen it when merging that patch. Looking
deeper, the patch is pointless, because the compiler will optimize the
checks away and use the proper CMP instruction to figure it out.

It's reverted now.

Thanks,

tglx