Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2017 08:45:23 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Colin Percival <cperciva@tarsnap.com>, cem@freebsd.org
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r321985 - head/sys/ofed/drivers/infiniband/core
Message-ID:  <d3c608fc-78e1-a04f-2525-3b17a33fae7d@selasky.org>
In-Reply-To: <0100015dabf99670-4b6c3f74-5f86-49a2-a3d5-85dee9e16f91-000000@email.amazonses.com>
References:  <201708030918.v739IPVY034866@repo.freebsd.org> <CAG6CVpVL49nVqRs5atub=d2P39EGOqcNtx_Raa8fWtV=BFZXbw@mail.gmail.com> <bd19c6f8-fa97-c9c5-6318-1778e38dd0a9@selasky.org> <0100015dabf99670-4b6c3f74-5f86-49a2-a3d5-85dee9e16f91-000000@email.amazonses.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/04/17 08:40, Colin Percival wrote:
>> Casting to "int" or truncating is the right thing to do in this case.
> Signed integer overflow is undefined.  Using 'int' is liable to cause problems
> after 2^32  ticks.
> 

Hi,

If you check the code how this function is used, you'll see that the 
argument passed is computed from:

jiffies + n, where "n" is a relatively small value.

The <= 0 check is basically there to catch cases where the jiffies value 
has changed between the point where it was set and the point where the 
relative ticks timeout value "n" was extracted.

Basically the code is doing like this, reading the value of "jiffies" twice.

delay = (jiffies0 + n) - jiffies1;

if (delay <= 0)
delay = 1;

And then "delay" should be "int", because we are usually not dealing 
with timeouts greater than a few hundred seconds or so.

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d3c608fc-78e1-a04f-2525-3b17a33fae7d>