From owner-freebsd-current@FreeBSD.ORG Wed Apr 30 13:20:35 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADCBB37B404 for ; Wed, 30 Apr 2003 13:20:35 -0700 (PDT) Received: from mail46.fg.online.no (mail46-s.fg.online.no [148.122.161.46]) by mx1.FreeBSD.org (Postfix) with ESMTP id 481F543F93 for ; Wed, 30 Apr 2003 13:20:32 -0700 (PDT) (envelope-from sigsegv@leakingmemory.org) Received: from radiotube.homeunix.org (ti531210a080-1902.bb.online.no [80.213.111.110]) by mail46.fg.online.no (8.9.3p2/8.9.3) with ESMTP id WAA13069; Wed, 30 Apr 2003 22:20:28 +0200 (MEST) From: Jan-Espen Pettersen To: Georg Funk Date: Wed, 30 Apr 2003 22:20:27 +0200 User-Agent: KMail/1.5 References: <200304301455.23334.georgfunk@web.de> <200304301633.21927.sigsegv@leakingmemory.org> <200304301828.37987.georgfunk@web.de> In-Reply-To: <200304301828.37987.georgfunk@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304302220.27479.sigsegv@leakingmemory.org> cc: freebsd-current@freebsd.org Subject: Re: lock order reversal X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: sigsegv@leakingmemory.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2003 20:20:36 -0000 On Wednesday 30 April 2003 18:28, Georg Funk wrote: > hm, the patch doesn't seem to work: > > -------------------------------------------------- > #patch < pcm.diff > Hmm... Looks like a normal diff to me... > The text leading up to this was: > -------------------------- > > |cvs diff: Diffing sys/dev/sound/pcm > |Index: sys/dev/sound/pcm/dsp.c > |=================================================================== > |RCS file: > > /old/pub/FreeBSD/development/FreeBSD-CVS/src/sys/dev/sound/pcm/dsp.c,v > > |retrieving revision 1.62 > |diff -r1.62 dsp.c > > -------------------------- > Patching file dsp.c using Plan A... > Hunk #1 failed at 265. > Hunk #2 failed at 270. > Hunk #3 failed at 287. > Hunk #4 succeeded at 304. > 3 out of 4 hunks failed--saving rejects to dsp.c.rej > done > > On Wednesday 30 April 2003 16:33, you wrote: > > On Wednesday 30 April 2003 14:55, Georg Funk wrote: > > > Hi! > > > I'm running the FreeBSD 5.0-RELEASE. When I boot up, this appears: > > > > > > 1st 0xc12a7230 process lock (process lock) @ > > > ../../../kern/kern_descrip.c:2112 lock order reversal > > > I haven't noticed any disfunctions, but what does this mean? > > > > > > I get a similar error when I use my soundcard: > > > > > > lock order reversal > > > 1st 0xc120a680 pcm0 (sound softc) @ ../../../dev/sound/isa/mss.c:177 > > > 2nd 0xc120a740 pcm0:play:0 (pcm channel) @ > > > ../../../dev/sound/pcm/channel.c:441 > > > > > > I have to restart the KDE artsd before the soundcard works correct. > > > Please give me advice how to solve this. > > > > > > Thanks in advance, Georg Funk > > > > I have also seen that problem, and this patch seems to work here.. > > It is probably not very optimized, but the lock order reversal didn't > > show up again... > > > > cvs diff: Diffing sys/dev/sound/pcm > > Index: sys/dev/sound/pcm/dsp.c > > =================================================================== > > RCS file: > > /old/pub/FreeBSD/development/FreeBSD-CVS/src/sys/dev/sound/pcm/dsp.c,v > > retrieving revision 1.62 > > diff -r1.62 dsp.c > > 265,266c265 > > < pcm_unlock(d); > > < /* finished with snddev, new channels still locked */ > > --- > > > > > /* keep the snddev lock to avoid a lock order reversal, new > > > channels still locked */ > > > > 271d269 > > < pcm_lock(d); > > 289d286 > > < pcm_lock(d); > > 306a304 > > > > > pcm_unlock(d); > > Sorry, I was in a hurry. I was supposed to be at work 30 minutes later... This one should work: --- dsp.c Wed Apr 30 22:15:50 2003 +++ /home/sigsegv/pcm/dsp.c Wed Apr 30 21:55:38 2003 @@ -262,13 +262,11 @@ i_dev->si_drv1 = rdch; i_dev->si_drv2 = wrch; - pcm_unlock(d); - /* finished with snddev, new channels still locked */ + /* keep the snddev lock to avoid a lock order reversal, new channels still locked */ /* bump refcounts, reset and unlock any channels that we just opened */ if (flags & FREAD) { if (chn_reset(rdch, fmt)) { - pcm_lock(d); pcm_chnrelease(rdch); i_dev->si_drv1 = NULL; if (wrch && (flags & FWRITE)) { @@ -286,7 +284,6 @@ } if (flags & FWRITE) { if (chn_reset(wrch, fmt)) { - pcm_lock(d); pcm_chnrelease(wrch); i_dev->si_drv2 = NULL; if (flags & FREAD) { @@ -304,6 +301,7 @@ pcm_chnref(wrch, 1); CHN_UNLOCK(wrch); } + pcm_unlock(d); splx(s); return 0; }