From owner-freebsd-current@FreeBSD.ORG Sat May 25 21:55:09 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B6262E41 for ; Sat, 25 May 2013 21:55:09 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ob0-x22c.google.com (mail-ob0-x22c.google.com [IPv6:2607:f8b0:4003:c01::22c]) by mx1.freebsd.org (Postfix) with ESMTP id 894C5A83 for ; Sat, 25 May 2013 21:55:09 +0000 (UTC) Received: by mail-ob0-f172.google.com with SMTP id tb18so6810701obb.17 for ; Sat, 25 May 2013 14:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=K57EHjJSo6v2LpYLl7dH3c55q34kcw4LPvZFeNrdlFA=; b=WFO/qP+4PiJW2k/5QkMP/Px+DW+DYsO6/r559j9al+YPnTaQF0K99rKaQT6Gq5HA64 aR/J54M8edPA7akRcjqrqywdbgLAdt+1J7xYGRQ6tgwJ/tEjnWldE3oBUFUhrKEoWthh 1JgQE0k5dxoZHOUIDHx4qIOF8bCNUTKeA9GbZ3M6Q8nGeMS1uZXM2Z41js/XCxYWsTgQ xIdWP+n3LHJi1Jrex1OjsI3pKLTQIjoEuxGxxmuhNhVTzCts71j5CLGE99Dcq33m6KBI ywFLkNsuDOBOKHLuU7kMo/a/1XiJsP0VSlvVG2y/R7eskhH7KLRpg5wVDLQIa1ASHgnZ 7rwA== MIME-Version: 1.0 X-Received: by 10.182.233.227 with SMTP id tz3mr15303941obc.23.1369518909147; Sat, 25 May 2013 14:55:09 -0700 (PDT) Received: by 10.76.90.10 with HTTP; Sat, 25 May 2013 14:55:09 -0700 (PDT) Date: Sat, 25 May 2013 17:55:09 -0400 Message-ID: Subject: Incorrect comparison of ticks in deadlkres From: Ryan Stone To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: arao@freebsd.og X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 21:55:09 -0000 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.