From owner-svn-src-head@freebsd.org Fri Aug 4 06:30:54 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D67DBDC91C9; Fri, 4 Aug 2017 06:30:54 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9EFD980112; Fri, 4 Aug 2017 06:30:54 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 65E0826015A; Fri, 4 Aug 2017 08:30:52 +0200 (CEST) Subject: Re: svn commit: r321985 - head/sys/ofed/drivers/infiniband/core To: cem@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201708030918.v739IPVY034866@repo.freebsd.org> From: Hans Petter Selasky Message-ID: Date: Fri, 4 Aug 2017 08:28:41 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 06:30:54 -0000 On 08/03/17 16:37, Conrad Meyer wrote: > Hey Hans, > > Is it not important that the subtraction and result are evaluated > without truncation? Hi, ticks is a circular counter. Assuming time = 0 and jiffies = -1U, then "delay" becomes a very large negative value, because long is used, and the delay <= 0 check, is no longer working like expected. Casting to "int" or truncating is the right thing to do in this case. --HPS > > Thanks, > Conrad > > On Thu, Aug 3, 2017 at 2:18 AM, Hans Petter Selasky > wrote: >> Author: hselasky >> Date: Thu Aug 3 09:18:25 2017 >> New Revision: 321985 >> URL: https://svnweb.freebsd.org/changeset/base/321985 >> >> Log: >> Ticks are 32-bit in FreeBSD. >> >> MFC after: 3 days >> Sponsored by: Mellanox Technologies >> >> Modified: >> head/sys/ofed/drivers/infiniband/core/addr.c >> >> Modified: head/sys/ofed/drivers/infiniband/core/addr.c >> ============================================================================== >> --- head/sys/ofed/drivers/infiniband/core/addr.c Thu Aug 3 09:14:43 2017 (r321984) >> +++ head/sys/ofed/drivers/infiniband/core/addr.c Thu Aug 3 09:18:25 2017 (r321985) >> @@ -187,10 +187,10 @@ EXPORT_SYMBOL(rdma_translate_ip); >> >> static void set_timeout(unsigned long time) >> { >> - unsigned long delay; >> + int delay; /* under FreeBSD ticks are 32-bit */ >> >> delay = time - jiffies; >> - if ((long)delay <= 0) >> + if (delay <= 0) >> delay = 1; >> >> mod_delayed_work(addr_wq, &work, delay); >> > >