From owner-freebsd-current@FreeBSD.ORG Sun Jan 9 10:15:32 2005 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 773AD16A4CE; Sun, 9 Jan 2005 10:15:32 +0000 (GMT) Received: from mail17.syd.optusnet.com.au (mail17.syd.optusnet.com.au [211.29.132.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id D477443D2D; Sun, 9 Jan 2005 10:15:31 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) j09AFU0B010280 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Sun, 9 Jan 2005 21:15:30 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])j09AFUxP047582; Sun, 9 Jan 2005 21:15:30 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost)j09AFTSw047581; Sun, 9 Jan 2005 21:15:29 +1100 (EST) (envelope-from pjeremy) Date: Sun, 9 Jan 2005 21:15:29 +1100 From: Peter Jeremy To: Scott Long Message-ID: <20050109101529.GM39552@cirb503493.alcatel.com.au> References: <20050109011132.GJ39552@cirb503493.alcatel.com.au> <41E0C02F.60100@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41E0C02F.60100@freebsd.org> User-Agent: Mutt/1.4.2i cc: freebsd-current@freebsd.org Subject: Re: bus_dmamem_alloc() can't handle large NOWAIT requests X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jan 2005 10:15:32 -0000 On Sat, 2005-Jan-08 22:25:03 -0700, Scott Long wrote: >>According to bus_dma(9), bus_dmamem_alloc() can be invoked with a >>flag BUS_DMA_NOWAIT to indicate that sleep()ing is not allowed. >> >>At least on the i386, if the requested size exceeds 1 page (or some >>other cases), the requested memory will be allocated via contigmalloc(). ... >Will contigmalloc() actually sleep? If so, then this is something that >needs to be addressed in contigmalloc. I have not actually seen this occur. If I get some time, I might see if I can force the issue. Reading the code, I believe it can. Firstly: 1) if (vm_old_contigmalloc), contigmalloc1() locks vm_page_queue_mtx via vm_page_lock_queues(). 2) Otherwise, contigmalloc2() calls vm_map_lock() which locks kernel_map->system_mtx Both these mutexes are MTX_DEF (sleepable) and there doesn't appear to be anything preventing them from sleeping. There are other theoretical code paths that end in sleeps (eg the following), though I suspect this path can never occur: contigmalloc() => vm_contig.c:552: contigmalloc1() => vm_contig.c:222,227: vm_contig_launder() => vm_contig.c:141: vm_contig_launder_page() => vm_contig.c:98: vm_page_sleep_if_busy() => vm_page.c:440: msleep() -- Peter Jeremy