Re: Incorrect comparison of ticks in deadlkres

From: Ryan Stone <rysto32_at_gmail.com>
Date: Tue, 28 May 2013 19:18:07 -0400
On Tue, May 28, 2013 at 5:29 PM, Ian Lepore <ian_at_freebsd.org> wrote:

> ticks is defined as a signed integer but conceptually it is unsigned --
> it increments from 0 to UINT_MAX (not INT_MAX) then rolls over.  If
> td->td_blktick is captured while ticks = UINT_MAX and later ticks has
> rolled over and counted back up to 15, then ticks - td->td_blktick gives
> an elapsed time of 16, as it should be.  Whether exploiting this
> property of signed overflow is elegant or ugly is in the eye of the
> beholder. :)
>
> If the intent of the "ticks < td->td_blktick" is to avoid the deadlock
> check until "after enough time has passed," then I guess it should
> probably be something more like "(ticks - td->blktick) > SOME_THRESHOLD"
> so that it also uses the signed overflow trick.
>
> -- Ian
>

It already does this later on to actually detect the deadlock.  The test is
reversed but was intended to bail and not calculate the time elapsed at all
if ticks had overflowed after td_blktick was captured, but as you say this
is unnecessary.
Received on Tue May 28 2013 - 21:18:15 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:38 UTC