Re: pcm & exclusive sleep mutex with Oct19 CURRENT
Hello Paolo, See below. On Oct 20, Paolo Pisati wrote: > from my dmesg: > [snip] > exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ > /usr/src/sys/dev/sound/pcm/mixer.c:322 Could you try deleting the snd_mtxlock and snd_mtxunlock in mixer_hwvol_init() in mixer.c? I think it's uneeded as the function is only called in particular device instance creation and no-one should be able touch it yet. > > acquiring duplicate lock of same type: "pcm channel" > 1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > 2nd pcm0:play:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > Stack backtrace: Please try my "wild guess" patch that is attached. I tried to re-arrange the routine to only hold one locked channel at a time. I suppose another option would be flag the lock type as having duplicates ok. --Mat -- If you optimize everything, you will always be unhappy. - Don Knuth --- dspold.cSun Sep 14 17:49:38 2003 +++ dsp.c Tue Oct 21 14:38:44 2003 @@ -174,6 +174,8 @@ intrmask_t s; u_int32_t fmt; int devtype; + int rdref; + int error; s = spltty(); d = dsp_get_info(i_dev); @@ -209,6 +211,8 @@ panic("impossible devtype %d", devtype); } + rdref = 0; + /* lock snddev so nobody else can monkey with it */ pcm_lock(d); @@ -251,67 +255,66 @@ return EBUSY; } /* got a channel, already locked for us */ - } - - if (flags & FWRITE) { - /* open for write */ - wrch = pcm_chnalloc(d, PCMDIR_PLAY, td->td_proc->p_pid, -1); - if (!wrch) { - /* no channel available */ - if (flags & FREAD) { - /* just opened a read channel, release it */ - pcm_chnrelease(rdch); - } - /* exit */ - pcm_unlock(d); - splx(s); - return EBUSY; - } - /* got a channel, already locked for us */ - } - - i_dev->si_drv1 = rdch; - i_dev->si_drv2 = wrch; - - /* Bump refcounts, reset and unlock any channels that we just opened, -* and then release device lock. -*/ - if (flags & FREAD) { if (chn_reset(rdch, fmt)) { pcm_chnrelease(rdch); i_dev->si_drv1 = NULL; - if (wrch && (flags & FWRITE)) { - pcm_chnrelease(wrch); - i_dev->si_drv2 = NULL; - } pcm_unlock(d); splx(s); return ENODEV; } + if (flags & O_NONBLOCK) rdch->flags |= CHN_F_NBIO; pcm_chnref(rdch, 1); CHN_UNLOCK(rdch); + rdref = 1; + /* +* Record channel created, ref'ed and unlocked +*/ } + if (flags & FWRITE) { - if (chn_reset(wrch, fmt)) { - pcm_chnrelease(wrch); - i_dev->si_drv2 = NULL; - if (flags & FREAD) { - CHN_LOCK(rdch); - pcm_chnref(rdch, -1); - pcm_chnrelease(rdch); - i_dev->si_drv1 = NULL; - } - pcm_unlock(d); - splx(s); - return ENODEV; + /* open for write */ + wrch = pcm_chnalloc(d, PCMDIR_PLAY, td->td_proc->p_pid, -1); + error = 0; + + if (!wrch) + error = EBUSY; /* XXX Right return code? */ + else if (chn_reset(wrch, fmt)) + error = ENODEV; + + if (error != 0) { + if (wrch) { + /* +* Free play channel +*/ + pcm_chnrelease(wrch); + i_dev->si_drv2 = NULL; } - if (flags & O_NONBLOCK) - wrch->flags |= CHN_F_NBIO; - pcm_chnref(wrch, 1); - CHN_UNLOCK(wrch); + if (rdref) { + /* +* Lock, deref and release previously created record channel +*/ + CHN_LOCK(rdch); + pcm_chnref(rdch, -1); + pcm_chnrelease(rdch); + i_dev->si_drv1 = NULL; + } + + pcm_unlock(d); + splx(s); + return error; + } + + if (flags & O_NONBLOCK) + wrch->flags |=
Re: pcm & exclusive sleep mutex with Oct19 CURRENT
On Mon, Oct 20, 2003 at 10:37:00AM -0700, Kris Kennaway wrote: > Unfortunately none of the sound developers have been interested in > looking at the locking problems in the code. =( > > acquiring duplicate lock of same type: "pcm channel" > > 1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > > 2nd pcm0:play:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > > Stack backtrace: > > > > with no backtrace at all. > > FWIW, the backtrace would have been reported on the system console. righty right kris, here we go: backtrace(c0836d0c,c2d41754,c0a257d1,c3,246) at backtrace+0x17 witness_lock(c2d347c0,8,c0a257d1,c3,c2d34500) at witness_lock+0x672 _mtx_lock_flags(c2d347c0,0,c0a257d1,c3,3) at _mtx_lock_flags+0xba pcm_chnalloc(c2d1f400,1,9e7c,,8) at pcm_chnalloc+0x56 dsp_open(c08f10f0,803,2000,c340d130,c06947a2) at dsp_open+0x19f spec_open(cf175a68,cf175b24,c069c6b2,cf175a68,0) at spec_open+0x30b spec_vnoperate(cf175a68,0,c08fe0e0,c340d130,c392b248) at spec_vnoperate+0x18 vn_open_cred(cf175bd8,cf175cd8,0,c3ef6880,20) at vn_open_cred+0x432 vn_open(cf175bd8,cf175cd8,0,20,c08f7b30) at vn_open+0x30 kern_open(c340d130,8ae2050,0,803,0) at kern_open+0x140 open(c340d130,cf175d10,c084f404,3ed,3) at open+0x30 syscall(1002f,893002f,bfbf002f,29a975b5,8ae2058) at syscall+0x2c0 Xint0x80_syscall() at Xint0x80_syscall+0x1d --- syscall (5), eip = 0x2853ed3f, esp = 0xbfbfb4fc, ebp = 0xbfbfb518 --- and backtrace(c0836dc3,c102f110,c08497be,c08497be,c0849659) at backtrace+0x17 witness_lock(c102f110,8,c0849659,148,0) at witness_lock+0x672 _mtx_lock_flags(c102f110,0,c0849659,148,3) at _mtx_lock_flags+0xba _vm_map_lock(c102f0b0,c0849659,148,c08f5de0,2b4) at _vm_map_lock+0x36 kmem_malloc(c102f0b0,1000,101,ce70a810,c07996f7) at kmem_malloc+0x3a page_alloc(c103a3c0,1000,ce70a803,101,c083326a) at page_alloc+0x27 slab_zalloc(c103a3c0,1,8,c084afa2,68c) at slab_zalloc+0xb7 uma_zone_slab(c103a3c0,1,c084afa2,68c,0) at uma_zone_slab+0xe6 uma_zalloc_internal(c103a3c0,0,1,0,c101f470) at uma_zalloc_internal+0x3e bucket_alloc(44,1,c084afa2,70b,0) at bucket_alloc+0x5e uma_zfree_arg(c101f3c0,ce77ae04,0,778,0) at uma_zfree_arg+0x2c6 swp_pager_meta_free_all(c30e5cb8,c0848f76,c0848edb,21a) at swp_pager_meta_free_a ll+0xf2 swap_pager_dealloc(c30e5cb8,1,c084af06,104,0) at swap_pager_dealloc+0x11a vm_pager_deallocate(c30e5cb8,0,c084a0eb,260,c084afa2) at vm_pager_deallocate+0x3 d vm_object_terminate(c30e5cb8,0,c084a0eb,207,c062d650) at vm_object_terminate+0x2 03 vm_object_deallocate(c30e5cb8,c2ee8d98,c30e5cb8,c2ee8d98,ce70a9c8) at vm_object_ deallocate+0x371 vm_map_entry_delete(c16d59d8,c2ee8d98,c0849834,8b6,0) at vm_map_entry_delete+0x3 b vm_map_delete(c16d59d8,0,bfc0,c16d59d8,c16d59d8) at vm_map_delete+0x383 vm_map_remove(c16d59d8,0,bfc0,356,804f2c4) at vm_map_remove+0x55 exec_new_vmspace(ce70ab88,c08c7ac0,c0830c69,296,0) at exec_new_vmspace+0x235 exec_elf32_imgact(ce70ab88,0,c08318b5,ff,c08f77e8) at exec_elf32_imgact+0x1b0 kern_execve(c2d38980,8051080,bfbffd1c,804f2c0,0) at kern_execve+0x38c execve(c2d38980,ce70ad10,c084f404,3ed,3) at execve+0x30 syscall(2f,2f,2f,1,bfbffd1c) at syscall+0x2c0 Xint0x80_syscall() at Xint0x80_syscall+0x1d --- syscall (59), eip = 0x280d683f, esp = 0xbfbffd0c, ebp = 0xbfbffd38 --- hope this helps. -- Paolo Italian FreeBSD User Group: http://www.gufi.org ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: pcm & exclusive sleep mutex with Oct19 CURRENT
On Mon, Oct 20, 2003 at 07:15:19PM +0200, Paolo Pisati wrote: > > from my dmesg: > [snip] > pcm0: port 0xb800-0xb8ff irq 5 at device 1.0 on pci2 > pcm0: failed to enable memory mapping! > pcm0: > malloc() of "64" with the following non-sleepable locks held: > exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ > /usr/src/sys/dev/sound/pcm/mixer.c:322 Unfortunately none of the sound developers have been interested in looking at the locking problems in the code. > acquiring duplicate lock of same type: "pcm channel" > 1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > 2nd pcm0:play:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 > Stack backtrace: > > with no backtrace at all. FWIW, the backtrace would have been reported on the system console. Kris pgp0.pgp Description: PGP signature
pcm & exclusive sleep mutex with Oct19 CURRENT
from my dmesg: [snip] pcm0: port 0xb800-0xb8ff irq 5 at device 1.0 on pci2 pcm0: failed to enable memory mapping! pcm0: malloc() of "64" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "64" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 malloc() of "16" with the following non-sleepable locks held: exclusive sleep mutex pcm0:mixer (pcm mixer) r = 0 (0xc2d34540) locked @ /usr/src/sys/dev/sound/pcm/mixer.c:322 [snip] and later today i got even this: acquiring duplicate lock of same type: "pcm channel" 1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 2nd pcm0:play:0 @ /usr/src/sys/dev/sound/pcm/sound.c:195 Stack backtrace: with no backtrace at all. [EMAIL PROTECTED] flag]$ uname -a FreeBSD southcross.skynet.org 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Sun Oct 19 12:07:09 CEST 2003 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/SOUTHCROSS i386 [EMAIL PROTECTED] flag]$ -- Paolo Italian FreeBSD User Group: http://www.gufi.org ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "[EMAIL PROTECTED]"