From owner-freebsd-stable@FreeBSD.ORG Thu Feb 23 15:35:17 2012 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B34C9106564A; Thu, 23 Feb 2012 15:35:17 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 00F6E8FC0C; Thu, 23 Feb 2012 15:35:16 +0000 (UTC) Received: by qaea17 with SMTP id a17so1742461qae.13 for ; Thu, 23 Feb 2012 07:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; bh=1JcHY4k6ay+mYANyL30n7YXDZ+xOB/KZWwJTjBXfofY=; b=IzTW6qH7YvZt5EqlKFM1i3Y4XtH7Ee9rC4KhrdYQQ7pjv/1SWPIEsbpOY8crv/G/6e xlilM+81heuaENOblUgLUGLBWt1VD9oLdePNuNZfRrVbncvcZJslwH3rEGw9Wxt/avQe txAJtlbUzjGG3spZfi+Dnn4XwfP9+7mM8zU/0= Received: by 10.229.106.17 with SMTP id v17mr1068518qco.145.1330009924984; Thu, 23 Feb 2012 07:12:04 -0800 (PST) Received: from kan.dyndns.org (c-24-63-226-98.hsd1.ma.comcast.net. [24.63.226.98]) by mx.google.com with ESMTPS id el3sm4595452qab.8.2012.02.23.07.12.03 (version=SSLv3 cipher=OTHER); Thu, 23 Feb 2012 07:12:03 -0800 (PST) Date: Thu, 23 Feb 2012 10:11:57 -0500 From: Alexander Kabaev To: "Desai, Kashyap" Message-ID: <20120223101157.0bb3f2ee@kan.dyndns.org> In-Reply-To: References: <20120223094611.GC32748@hoeg.nl> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.6; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/950qJ=4tk1nASHapQ0CY+jC"; protocol="application/pgp-signature" Cc: Ed Schouten , freebsd-stable , "joerg@FreeBSD.org" , "Kenneth D. Merry" , "freebsd-scsi@freebsd.org" , "Justin T. Gibbs" , "McConnell, Stephen" Subject: Re: mpslsi0 : Trying sleep, but thread marked as sleeping prohibited X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 15:35:17 -0000 --Sig_/950qJ=4tk1nASHapQ0CY+jC Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 23 Feb 2012 18:45:29 +0530 "Desai, Kashyap" wrote: >=20 >=20 > > -----Original Message----- > > From: Ed Schouten [mailto:ed@80386.nl] > > Sent: Thursday, February 23, 2012 3:16 PM > > To: Desai, Kashyap > > Cc: freebsd-scsi@freebsd.org; freebsd-stable; joerg@FreeBSD.org; > > Kenneth D. Merry; McConnell, Stephen; Justin T. Gibbs > > Subject: Re: mpslsi0 : Trying sleep, but thread marked as sleeping > > prohibited > >=20 > > Hi Kashyap, > >=20 > > * Desai, Kashyap , 20120222 18:51: > > > Adding Ed Schouten and Jorg Wunsch as I see there are author of > > > msleep/mtx related APIs. > >=20 > > Am I? :-) > I am new to FreeBSD and desperate to know the answer. :-). Thanks for > your help. > >=20 > > > 1. When any irq is register with FreeBSD OS, it sets " > > > TDP_NOSLEEPING" pflag. It means though irq in freebsd is treated > > > as thread, We cannot sleep in IRQ because of " "TDP_NOSLEEPING " > > > set. 2. In mps driver we have below code snippet in ISR routine. > > > > > > > > > mps_dprint(sc, MPS_TRACE, "%s\n", __func__); > > > mps_lock(sc); > > > mps_intr_locked(data); > > > mps_unlock(sc); > > > > > > I wonder why there is no issue with above code ? Theoretical we > > > cannot sleep in ISR. (as explained in #1) Any thoughts ? > >=20 > > The TDP_NOSLEEPING flag only disallows sleeping of an indeterminate > > amount of time. Locking a mutex is allowed, as it can only cause the > > thread to be blocked for a small amount of time, waiting for another > > thread to unlock it. > So does this assumption that another thread will release mutex fast > enough ? Same as msleep() this can be applicable here as well. I mean > another thread _can_ (if some bad drivers) take long time to release > mutex. >=20 > Bad drivers can just defererence wild pointer to satisfy their need for wrongdoing. For that reason let us keep them out of conversation. mtx locks were designed to protect small sections of code where thread is only allowed to block waiting for other thread to release the lock of similar class. While threads are blocked, they get benefit of adaptive sleep and priority propagation and should take precaution of never taking the path of code that can cause them to sleep. Assertions are there to help code authors with that. sleep locks are by definition unbound. There is no spinning, no priority propagation. Holders are free to take, say, page faults and go to long journey to disk and back, etc. Hardly the stuff _anyone_ would want to do from interrupt handler, thread or otherwise.=20 =20 > > > 3. I recently added few place msleep() instead of DELAY in ISR > > > context and I see " Trying sleep, but thread marked as sleeping > > > prohibited". > >=20 > > Which makes sense, as msleep() can be used to sleep for > > indefinitely. > This part is clear. ! I agree with all experts view.=20 > >=20 > > -- > > Ed Schouten > > WWW: http://80386.nl/ > _______________________________________________ > freebsd-scsi@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-scsi > To unsubscribe, send any mail to > "freebsd-scsi-unsubscribe@freebsd.org" --=20 Alexander Kabaev --Sig_/950qJ=4tk1nASHapQ0CY+jC Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iD8DBQFPRldCQ6z1jMm+XZYRAhIbAKDOazJ5UXmFRvE7uTT33ev2At+N0wCgymJR 5k9bxKRjkXtb4o5H6isoJVM= =1ndl -----END PGP SIGNATURE----- --Sig_/950qJ=4tk1nASHapQ0CY+jC--