From owner-freebsd-arch@FreeBSD.ORG Thu Nov 13 02:26:21 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 25922E67; Thu, 13 Nov 2014 02:26:21 +0000 (UTC) Received: from mail-qc0-x22b.google.com (mail-qc0-x22b.google.com [IPv6:2607:f8b0:400d:c01::22b]) (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 CDB12CBE; Thu, 13 Nov 2014 02:26:20 +0000 (UTC) Received: by mail-qc0-f171.google.com with SMTP id m20so10369482qcx.16 for ; Wed, 12 Nov 2014 18:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; bh=JFeuz8bZ0zxb4U17uSmuFV0B7FRBiba1SWYWNT9fFgs=; b=tpqTBw8uT35DewjBWffv2d/pDCthDd9IuxzLCbDea98U2WXXj/lJrdlURzMEYeNnhi GYs7dun1YXfLmQoBTSGUYnppFTCUZ+Mf/dxHOZsVBiDtgxblLfczMo8phk9/IxjDkPps +SMtS4d1AtdsBBCzsrzXiW467HYX1f33bdpqmXashnDgasVpu7jBBRta2mQ00KRcREBo xelR0I9fxPkPtpJ1PHXzHO2hlczGOOCItOE9srW+wq+OdLqN7cnhf/yzqP2hlbc0z1An DfpZySpriuABF8V4hZ6bgk62pqYrwWJ+yUD5NG1sg1fLJJXIcnInx4wTedoi8sMc5hh4 iI7g== X-Received: by 10.140.44.36 with SMTP id f33mr62379255qga.105.1415845579944; Wed, 12 Nov 2014 18:26:19 -0800 (PST) Received: from kan ([2601:6:6780:7e0:226:18ff:fe00:232e]) by mx.google.com with ESMTPSA id z32sm22748232qgd.40.2014.11.12.18.26.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Nov 2014 18:26:19 -0800 (PST) Date: Wed, 12 Nov 2014 21:26:13 -0500 From: Alexander Kabaev To: Adrian Chadd Subject: Re: Questions about locking; turnstiles and sleeping threads Message-ID: <20141112212613.21037929@kan> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.22; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/Xb6osdN4Oqbwi=eEkl3Fapy"; protocol="application/pgp-signature" Cc: "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 02:26:21 -0000 --Sig_/Xb6osdN4Oqbwi=eEkl3Fapy Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 12 Nov 2014 18:13:55 -0800 Adrian Chadd wrote: > Hi, >=20 > I have a bit of an odd case here. >=20 > I'm getting panics in the net80211/ath code, "sleeping thread (X) owns > non-sleepable lock." >=20 > show alllocks just showed one lock held - the net80211 comlock. It's a > recursive mutex, that's supposed to be sleepable. >=20 > The two threads in question look like this: >=20 > thread X: net80211_newstate_cb (grabs IEEE80211_LOCK()) > ath_newstate > callout_drain - which grabs the ATH_LOCK as part of the callout > drain side of things > that enters sleepq_wait() and goes to sleep, waiting for > whatever's running the callout to > finish >=20 > thread Y: > rx_path in if_ath_rx_edma > ath_rx_pkt -> sta_input -> ath_recv_mgmt -> sta_recv_mgmt (grabs > IEEE80211_LOCK()) -> panics >=20 > Thread Y doesn't hold any other locks. It's just trying to grab the > IEEE80211_LOCK that is being held by thread X. But thread X is asleep > waiting for whatever callout to finish so it can continue. The code in > propagate_priority() sees that thread X is sleeping and panics. >=20 > So, what's really going on? I don't mind (well, "don't mind") having > to take another deep dive through all of this to sort it out so it > doesn't tickle the callout / turnstile code in this particular > fashion, but I'd first like to ensure that it's not some corner case > that isn't handled by the check in propagate_priority(). >=20 > Thanks, >=20 >=20 > -adrian > _______________________________________________ Hi, mutexes are blocking and not sleepable primitives, so doing any unbounded sleep with mutex locked, such as one you are attempting by calling callout_drain is illegal. In other words, you are getting an expected assert and the code in question is wrong. --=20 Alexander Kabaev --Sig_/Xb6osdN4Oqbwi=eEkl3Fapy Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iD8DBQFUZBbKQ6z1jMm+XZYRAlweAJwNJIf8jm8HQineNZpI5O0mF9prVACeKWUM a/Fbvs0x7U/dY6itBVE7w2E= =bOf1 -----END PGP SIGNATURE----- --Sig_/Xb6osdN4Oqbwi=eEkl3Fapy--