From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751752AbbEAS36 (ORCPT ); Fri, 1 May 2015 14:29:58 -0400 Received: from mail-qc0-f177.google.com ([209.85.216.177]:33874 "EHLO mail-qc0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbbEAS3z (ORCPT ); Fri, 1 May 2015 14:29:55 -0400 Date: Fri, 1 May 2015 14:29:52 -0400 (EDT) From: Nicolas Pitre To: John Stultz cc: Trevor Cordes , lkml , Thomas Gleixner , Josh Boyer , One Thousand Gnomes Subject: Re: regression in ktime.h circa 3.16.0-rc5+ breaks lirc irsend, bad commit 166afb64511 In-Reply-To: Message-ID: References: <20150323165725.GA25008@pog.tecnopolis.ca> <20150429232721.59b89cb1@pog.tecnopolis.ca> <20150501050225.4c0ac17c@pog.tecnopolis.ca> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 May 2015, John Stultz wrote: > So yea. I see the issue now. The ktime_divns() function uses do_div > which is an unsigned divide. So negative numbers look like large > numbers, and it doesn't do sign-extension, so when it divides we lose > the sign bit. That doesn't stop there. On 32-bit systems, if the divisor is not constant or too large, then __ktime_divns() is used. If you look at the code for __ktime_divns(), you'll notice it would get into an infinite loop if you pass it a negative divisor. Nicolas