From owner-freebsd-hackers Wed Mar 13 14:10:13 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from web.cs.ndsu.nodak.edu (web.cs.ndsu.NoDak.edu [134.129.125.7]) by hub.freebsd.org (Postfix) with ESMTP id AA8A537B400 for ; Wed, 13 Mar 2002 14:10:07 -0800 (PST) Received: (from tinguely@localhost) by web.cs.ndsu.nodak.edu (8.11.4/8.11.4) id g2DMA6s15248; Wed, 13 Mar 2002 16:10:06 -0600 (CST) (envelope-from tinguely) Date: Wed, 13 Mar 2002 16:10:06 -0600 (CST) From: mark tinguely Message-Id: <200203132210.g2DMA6s15248@web.cs.ndsu.nodak.edu> To: gjohnson@research.canon.com.au, tinguely@web.cs.ndsu.nodak.edu Subject: Re: DMA memory allocation/deallocation Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <20020313204049.13A80540D0@brixi.research.canon.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Thanks for the reply Mark, I tracked my problem down. In > 'bus_dmamem_alloc', 'contigmalloc' is used if the size is > greater than PAGE_SIZE. However, in 'bus_dmamem_free' > the same PAGE_SIZE check is performed, but nothing is > done for the case where the size is greater than PAGE_SIZE. > > So I then called contigfree explicitly in my code, and the > memory is released. > you may want a bugreport. > Another problem though, I am allocating a large DMAable buffer > ~300MB. I get to allocate this and free this twice on our system > (512MB memory). However, when I try a third time to load my device > driver and allocate the memory, it fails. Subsequent attempts > also fail. > > It seems that something is allocating in the middle of my > nice big free buffer. > > Does 'contigalloc' do anything sensible like shuffling arround > of pages in physical memory to make room for the requested amount > of space? It tries to squeeze out pageable memory, but it is not always successful. no other re-arranging is done because we don't know all the pointers and devices that are using that memory. but since most allocations are done by grabbing the first available chunk that works, you can try the trick of allocating the big things towards the end of the memory range and work your way backwards, unfortunately that would mean bypassing the politically correct way of allocating the buffer by using bus_dmamem_alloc(). Evenually that trick will fail too. You can make that memory "static", by not really releasing it. Of course no one else can use it either. the contig allocation leak I alluded to was if you have lots of physical memory, but did not expand the kernel virtual map. then we don't put back the contiguous memory back into the available array. since you should have a kernel virtual of at least 1GB and only physical of 512MB, you are not hitting this situation. --mark tinguely. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message