Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2013 01:31:13 +0200
From:      Attilio Rao <attilio@freebsd.org>
To:        Ryan Stone <rysto32@gmail.com>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>, Ian Lepore <ian@freebsd.org>, arao@freebsd.og
Subject:   Re: Incorrect comparison of ticks in deadlkres
Message-ID:  <CAJ-FndDAwZkVN_Uku3KeLhK=bFQAPWCFgW1YJ5=zu-LL_jORZA@mail.gmail.com>
In-Reply-To: <CAFMmRNyeMXyJ4sNQKyibXyDza7dLKnRNYAVrPEEcg5LnGkm-Qw@mail.gmail.com>
References:  <CAFMmRNyQCs-yOB7gm4TRq3xcMp50PEJc0YNQLAjMs3q8iE-ZUw@mail.gmail.com> <CAJ-FndARggoG_scOWxzPNhJQA3foc_dW7-wtcm9b4_AG3OsVqg@mail.gmail.com> <1369776586.1258.19.camel@revolution.hippie.lan> <CAFMmRNyeMXyJ4sNQKyibXyDza7dLKnRNYAVrPEEcg5LnGkm-Qw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, May 29, 2013 at 1:18 AM, Ryan Stone <rysto32@gmail.com> wrote:
> 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.

I'm not sure if there was a comparison between the 2 values (ticks,
td_slpticks) somewhere, but if there is not and only add/sub to the
relative values then it is good to be removed.

Attilio


--
Peace can only be achieved by understanding - A. Einstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-FndDAwZkVN_Uku3KeLhK=bFQAPWCFgW1YJ5=zu-LL_jORZA>