From owner-freebsd-current@FreeBSD.ORG Sat Nov 24 15:01:42 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 632706A9; Sat, 24 Nov 2012 15:01:42 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9C5A58FC08; Sat, 24 Nov 2012 15:01:40 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id go10so6847320lbb.13 for ; Sat, 24 Nov 2012 07:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=GHyIzlRJ2d05wThFT2PJCqJ+dd36JbEcT9vycS6ZK+E=; b=f1IOQJNNfZjRR6YLvBuo5CUGTE1B9CdMGPTBZ6FbxgRnwKBkjb4Vvgr3ItaZuVUb5V t2xdA7h+BwdLbgRrDPKLixJtxv6GIAhu+Io7CeEVNes8UqgR2TKy97awI45DtinG/Afm qBMUbr78BucTG4crGp5MrAYKLqvqcYKd+OJrQIMseQeuyOaQ8M+/LvtU/Z/40D6OmroP olYcerAFoVcpB2L0pTVL0uNV44KRZ+5V0WiuA1vNcER3pyv1/FK3cFQnngLSjvTGtR7f zeAv+sca0fLf+t5nFWleEdnv9LZScku7xBIiuBhaO9NGhWF8slNu491AvW1sCAOTkSET Zn0A== MIME-Version: 1.0 Received: by 10.152.162.1 with SMTP id xw1mr6301907lab.3.1353769300071; Sat, 24 Nov 2012 07:01:40 -0800 (PST) Sender: asmrookie@gmail.com Received: by 10.112.134.5 with HTTP; Sat, 24 Nov 2012 07:01:39 -0800 (PST) In-Reply-To: References: Date: Sat, 24 Nov 2012 15:01:39 +0000 X-Google-Sender-Auth: Zr32j1vTKyIjGT-_Bc7aMC6fxao Message-ID: Subject: Re: Spurious witness warning when destroying spin mtx From: Attilio Rao To: Ryan Stone , John Baldwin Content-Type: text/plain; charset=UTF-8 Cc: FreeBSD Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Nov 2012 15:01:42 -0000 On Sat, Nov 24, 2012 at 3:08 AM, Ryan Stone wrote: > Today I saw a spurious witness warning for "acquiring duplicate lock of > same type". The root cause is that when running mtx_destroy on a spinlock > that is held by the current thread, mtx_destroy calls spinlock_exit() > before calling WITNESS_UNLOCK, which opens up a window in which the CPU can > be interrupted and attempt to acquire another spinlock of the same type as > the one being destroyed. This patch should fix it: I seriously wonder why right now we don't assume the lock is unheld. There are likely historically reasons for that, but I would like to know which one are those and eventually fix them out. FWIK, all the other locking primitives assume the lock is already unheld when destroying and I think it would be good to have that for mutexes as well. Can you please show which lock triggers the panic you saw? Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein