From owner-freebsd-current@FreeBSD.ORG Sun Nov 25 12:49:48 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 3AEBA47B; Sun, 25 Nov 2012 12:49:48 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 72F698FC08; Sun, 25 Nov 2012 12:49:47 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so9823353lah.13 for ; Sun, 25 Nov 2012 04:49:44 -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=Ye3+vD0gXN4d4ZfjBlrPSS8t84n3qTqJn0KxZWwxcrA=; b=oWxHKG9JrWdcCiwuXqVfETUqzgxrRNH5A5l2GeWTirUOhl66P+POIAyWZkZPsie0yx iSfUZ6LvB0QO6euvDrhMRGS6WWEJiv9W4mFCEm8vzJ2qzNK7c/Dl70Zn33uNofzb/nDr RfrTYEoq72zNW9iJI9D/ImJZScVleEhZZnNb9/vwZkGitxnRRrfV5IVh5L84obb8IA7E GfINf3oCKHfUDZHdY4Cb7IqWDE7H8ctntyIzmbe5cBkVNCSjnIHcwkUYB8TDrQ1MyO1m bPI07AVbKQ0TKU02uXs/PDL+9rcoGrrQCX3BUaO43YslpjLf0u5j9Ux7ZcpqBPf6oDP7 sSMw== MIME-Version: 1.0 Received: by 10.112.26.67 with SMTP id j3mr3945437lbg.39.1353847784627; Sun, 25 Nov 2012 04:49:44 -0800 (PST) Sender: asmrookie@gmail.com Received: by 10.112.134.5 with HTTP; Sun, 25 Nov 2012 04:49:44 -0800 (PST) In-Reply-To: References: Date: Sun, 25 Nov 2012 12:49:44 +0000 X-Google-Sender-Auth: RkY4p3ghi-Wpi21JavQrwsPneNo 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: Sun, 25 Nov 2012 12:49:48 -0000 On Sat, Nov 24, 2012 at 3:01 PM, Attilio Rao wrote: > 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? Ryan, however I'm sure this patch would introduce a major switch in our KPI/POLA and eventually it would be a bigger work. Your patch is certainly right and I think you should commit it for the time being. For the long-term, maybe you would like to work on such a patch, rather. Attilio -- Peace can only be achieved by understanding - A. Einstein