From owner-freebsd-current@FreeBSD.ORG Tue Jan 11 15:10:44 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 E7B5516A4CE for ; Tue, 11 Jan 2005 15:10:44 +0000 (GMT) Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id E6E0B43D5E for ; Tue, 11 Jan 2005 15:10:41 +0000 (GMT) (envelope-from john@baldwin.cx) Received: (qmail 16883 invoked from network); 11 Jan 2005 15:10:41 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 11 Jan 2005 15:08:21 -0000 Received: from [192.168.0.15] (osx.baldwin.cx [192.168.0.15]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id j0BF8D43018321; Tue, 11 Jan 2005 10:08:13 -0500 (EST) (envelope-from john@baldwin.cx) In-Reply-To: <20050109101529.GM39552@cirb503493.alcatel.com.au> References: <20050109011132.GJ39552@cirb503493.alcatel.com.au> <41E0C02F.60100@freebsd.org> <20050109101529.GM39552@cirb503493.alcatel.com.au> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <9D0B94DA-63E2-11D9-A25E-000393921CC4@baldwin.cx> Content-Transfer-Encoding: 7bit From: John Baldwin Date: Tue, 11 Jan 2005 10:08:13 -0500 To: Peter Jeremy X-Mailer: Apple Mail (2.619) X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx X-Mailman-Approved-At: Wed, 12 Jan 2005 14:26:47 +0000 cc: freebsd-current@freebsd.org cc: Scott Long 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: Tue, 11 Jan 2005 15:10:45 -0000 On Jan 9, 2005, at 5:15 AM, Peter Jeremy wrote: > 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. Unforunately, "sleep" is a bit of an overloaded term in the kernel. Blocking on a mutex is not considered a "sleep" quite like msleep() or cv_wait() in that a mutex will eventually be released (barring an infinite loop bug) and thus a thread blocked on a lock won't sleep forever. msleep() and cv_wait() on the other hand do not have the same guarantee. M_NOWAIT means that msleep() and cv_wait() won't be called; it is ok to block on a mutex with M_NOWAIT however. I tried to explain this difference in semantics some in the glossary of the SMP chapter in the kernel devbook. > -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org