Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 May 2013 17:55:09 -0400
From:      Ryan Stone <rysto32@gmail.com>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Cc:        arao@freebsd.og
Subject:   Incorrect comparison of ticks in deadlkres
Message-ID:  <CAFMmRNyQCs-yOB7gm4TRq3xcMp50PEJc0YNQLAjMs3q8iE-ZUw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Currently deadlkres performs the following comparison when trying to check
for threads that have been blocked on a mutex or sleeping on an sx lock:

if (TD_ON_LOCK(td) && ticks < td->td_blktick) {
    /* check for deadlock...*/


The test against ticks is incorrect.  It results in deadlkres only
signaling a deadlock after ticks has rolled over; at 1000 hz this will take
up to 49 days.  From looking at the history of the code this test appears
to be a attempt to deal with ticks rollover.  However this is necessary;
later on the code calculates the amount of time that has passed with:

tticks = ticks - td->td_blktick;

ticks was designed to exploit integer underflow in the case of rollover to
guarantee that subtraction produces correct results in all cases (other
than a double rollover, of course).  I am going to remove the two incorrect
tests unless somebody can point out a overflow/underflow case that I
haven't considered.



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