From owner-freebsd-arch@FreeBSD.ORG Thu Nov 13 17:31:41 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8D0976A5; Thu, 13 Nov 2014 17:31:41 +0000 (UTC) Received: from mail-wg0-x235.google.com (mail-wg0-x235.google.com [IPv6:2a00:1450:400c:c00::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 18230B67; Thu, 13 Nov 2014 17:31:41 +0000 (UTC) Received: by mail-wg0-f53.google.com with SMTP id b13so17494796wgh.12 for ; Thu, 13 Nov 2014 09:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=WMUQxXyKgzJR8dxW5YPni21SELfVwsePu9xAPBYRrNA=; b=D/XU8/Ae3tYu6Q9k3DwH4hoUyVYqQFP957lqfr6VfYpN4a5gQqQDEa2wd8BQLueBQR CdZ/6QE9nKCkmtkjcwodwV2ZECpH4vRGHFx781zQC/HoSRvGnTo31BKvoijG93cn6Ohe 8sDsIb9QNUgK8E6hHow1OanLme4vcdVQccKac3qFOjlU7LXlHTbn0f5hMz3VSqsZT5MU YCd8LxRsUaKJIjv4CBZ20l4Uv2nxMjefjvewf0HNJZwMGQr/HMz+jNeUhtwb6smTdgX0 irxt5uZCyvzDbBQ83fw5mTGFLbRtTPOre+ZVD36tM2vdnX7qdhQR7Pa0uOj6fuOmPYk5 C9yg== MIME-Version: 1.0 X-Received: by 10.180.87.33 with SMTP id u1mr392066wiz.20.1415899899486; Thu, 13 Nov 2014 09:31:39 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Thu, 13 Nov 2014 09:31:39 -0800 (PST) In-Reply-To: <54648483.5060107@freebsd.org> References: <20141112212613.21037929@kan> <546472DA.3080006@freebsd.org> <5464764E.9080308@freebsd.org> <54647D1E.9010904@freebsd.org> <54648483.5060107@freebsd.org> Date: Thu, 13 Nov 2014 09:31:39 -0800 X-Google-Sender-Auth: NNe0Rpb6admvFeEe_aGwTbRWm6Q Message-ID: Subject: Re: Questions about locking; turnstiles and sleeping threads From: Adrian Chadd To: Alfred Perlstein Content-Type: text/plain; charset=UTF-8 Cc: Hans Petter Selasky , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Nov 2014 17:31:41 -0000 On 13 November 2014 02:14, Alfred Perlstein wrote: > Would need more context to help on this. > > I can't tell based on your description which thread is holding which lock. > > If A is waiting for callout C to stop AND there exists a thread B that is > contending against C for a lock, you should be fine so long as there is no > lock cycle against A. > > Would be best if you pointed at some code and gave descriptions. I haven't dug into the USB side of things ,but on the atheros side I gave the description above. Thread A grabs lock X and tries to drain callout, which involves grabbing lock Y to do the dirty work. Lock Y isn't held at this point - the callout is about to run or is running, so it enters the sleepq call to finish the drain. Thread B wants to grab lock X, but can't because thread A holds lock X and is in a sleepq due to callout_drain(). Hence panic. I'll poke people on IRC today and see if I can get a better description of what/where the WITNESS_WARN() should be placed in callout_drain(). Then we'll see what's left triggering it. -adrian