From owner-freebsd-current@FreeBSD.ORG  Tue Feb 24 07:27:30 2004
Return-Path: <owner-freebsd-current@FreeBSD.ORG>
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 B9CF416A4CE; Tue, 24 Feb 2004 07:27:30 -0800 (PST)
Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 7EB6B43D2D; Tue, 24 Feb 2004 07:27:30 -0800 (PST)
	(envelope-from truckman@FreeBSD.org)
Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2])
	by gw.catspoiler.org (8.12.9p2/8.12.9) with ESMTP id i1OFRC7E074338;
	Tue, 24 Feb 2004 07:27:17 -0800 (PST)
	(envelope-from truckman@FreeBSD.org)
Message-Id: <200402241527.i1OFRC7E074338@gw.catspoiler.org>
Date: Tue, 24 Feb 2004 07:27:12 -0800 (PST)
From: Don Lewis <truckman@FreeBSD.org>
To: kuriyama@imgsrc.co.jp
In-Reply-To: <7mwu6dgn15.wl@black.imgsrc.co.jp>
MIME-Version: 1.0
Content-Type: TEXT/plain; charset=us-ascii
cc: cg@FreeBSD.org
cc: freebsd-current@FreeBSD.org
cc: mat@cnd.mcgill.ca
Subject: Re: exclusive sleep mutex pcm0 (sound cdev) r = 0
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.1
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
	<freebsd-current.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 24 Feb 2004 15:27:30 -0000

On 24 Feb, Jun Kuriyama wrote:
> 
> I got this warning on my current box:
> 
> malloc() of "256" with the following non-sleepable locks held:
> exclusive sleep mutex pcm0 (sound cdev) r = 0 (0xc73e63c0) locked @ dev/sound/pcm/dsp.c:213
> 
> I think there is no need to wait in vchan_create().  If kernel does
> not have resources to return small 256 bytes memory for sound device,
> we are not in the situation to care whether sound is played correctly
> or not...

There are a bunch more problems with the "sound cdev" mutex, many of
which can't be fixed by this type of change unless having sporadic sound
system failures due to temporary malloc() failures is acceptable.

I currently have some patches for the channel mutexes that are
undergoing testing.  Once these have been committed, I'll take another
look at the "sound cdev" mutex.  My current thought is to convert most
uses of it to a lockmgr lock.

> Index: vchan.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/dev/sound/pcm/vchan.c,v
> retrieving revision 1.16
> diff -u -r1.16 vchan.c
> --- vchan.c	28 Jan 2004 08:02:15 -0000	1.16
> +++ vchan.c	24 Feb 2004 03:35:19 -0000
> @@ -255,7 +255,7 @@
>  
>     	CHN_UNLOCK(parent);
>  
> -	pce = malloc(sizeof(*pce), M_DEVBUF, M_WAITOK | M_ZERO);
> +	pce = malloc(sizeof(*pce), M_DEVBUF, M_NOWAIT | M_ZERO);
>  	if (!pce) {
>     		CHN_LOCK(parent);
>  		return ENOMEM;
> 
>