Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 2013 19:18:07 -0400
From:      Ryan Stone <rysto32@gmail.com>
To:        Ian Lepore <ian@freebsd.org>
Cc:        Attilio Rao <attilio@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>, arao@freebsd.og
Subject:   Re: Incorrect comparison of ticks in deadlkres
Message-ID:  <CAFMmRNyeMXyJ4sNQKyibXyDza7dLKnRNYAVrPEEcg5LnGkm-Qw@mail.gmail.com>
In-Reply-To: <1369776586.1258.19.camel@revolution.hippie.lan>
References:  <CAFMmRNyQCs-yOB7gm4TRq3xcMp50PEJc0YNQLAjMs3q8iE-ZUw@mail.gmail.com> <CAJ-FndARggoG_scOWxzPNhJQA3foc_dW7-wtcm9b4_AG3OsVqg@mail.gmail.com> <1369776586.1258.19.camel@revolution.hippie.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 28, 2013 at 5:29 PM, Ian Lepore <ian@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNyeMXyJ4sNQKyibXyDza7dLKnRNYAVrPEEcg5LnGkm-Qw>