From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 2 14:56:29 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDC50106573B for ; Mon, 2 Feb 2009 14:56:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id A761A8FC2D for ; Mon, 2 Feb 2009 14:56:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 3B1CE46B32; Mon, 2 Feb 2009 09:56:29 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n12EuHRs040398; Mon, 2 Feb 2009 09:56:23 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Mon, 2 Feb 2009 08:45:21 -0500 User-Agent: KMail/1.9.7 References: <02026848-7F83-405C-B4F3-EDD8B47DA294@gmail.com> <32679C0A-28C1-4D7A-950C-580787F3971D@gmail.com> In-Reply-To: <32679C0A-28C1-4D7A-950C-580787F3971D@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200902020845.21773.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 02 Feb 2009 09:56:23 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8940/Mon Feb 2 07:31:54 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Nikola =?utf-8?q?Kne=C5=BEevi=C4=87?= Subject: Re: blockable sleep lock (sleep mutex) 16 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 14:56:31 -0000 On Monday 02 February 2009 7:33:08 am Nikola Kne=C5=BEevi=C4=87 wrote: > On 30 Jan 2009, at 18:11 , Nikola Kne=C5=BEevi=C4=87 wrote: >=20 > > This is the message buffer: > > Unread portion of the kernel message buffer: > > panic: blockable sleep lock (sleep mutex) 16 @ /usr/src/sys/vm/=20 > > uma_core.c:1834 >=20 > > Any hints where I should search for the cause? >=20 >=20 > Ok, I solved this problem. I had a critical_enter/exit surrounding =20 > code which was calling a lot of mallocs. Now, I'm getting another =20 > message, which doesn't make any sense: >=20 > ---8<--- > --- trap 0, rip =3D 0, rsp =3D 0xffffffff87834d30, rbp =3D 0 --- > uma_zalloc_arg: zone "256" with the following non-sleepable locks held: > exclusive sleep mutex click_instance r =3D 0 (0xffffff00051b4540) locked = =20 > @ sched.cc:441 > --->8--- >=20 > It says "non-sleepable locks", yet it classifies click_instance as =20 > sleep mutex. I think witness code should emit messages which are more =20 > clear. It is confusing, but you can't do an M_WAITOK malloc while holding a mutex.= =20 Basically, sleeping actually means calling "*sleep() (such as mtx_sleep()) = or=20 cv_*wait*()". Blocking on a mutex is not sleeping, it's "blocking". Some= =20 locks (such as sx(9)) do "sleep" when you contest them. In the scheduler,= =20 sleeping and blocking are actually quite different (blocking uses turnstile= s=20 that handle priority inversions via priority propagation, sleeping uses sle= ep=20 queues which do not do any of that). The underyling idea is that mutexes=20 should be held for "short" periods of time, and that any sleeps are=20 potentially unbounded. Holding a mutex while sleeping could result in a=20 mutex being held for a long time. =2D-=20 John Baldwin