From owner-freebsd-hackers Fri Nov 15 15:48: 1 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD1A237B401 for ; Fri, 15 Nov 2002 15:47:59 -0800 (PST) Received: from falcon.mail.pas.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4D7FA43E4A for ; Fri, 15 Nov 2002 15:47:59 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0182.cvx22-bradley.dialup.earthlink.net ([209.179.198.182] helo=mindspring.com) by falcon.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 18CqBh-0002La-00; Fri, 15 Nov 2002 15:47:50 -0800 Message-ID: <3DD58757.1936774C@mindspring.com> Date: Fri, 15 Nov 2002 15:46:31 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Chuck Tuffli Cc: mark tinguely , freebsd-hackers@FreeBSD.ORG Subject: Re: bus_dmamem_alloc failing References: <20021115164813.GB19814@cre85086tuf.rose.agilent.com> <200211151703.gAFH3ij16483@web.cs.ndsu.nodak.edu> <20021115175028.GC19814@cre85086tuf.rose.agilent.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Chuck Tuffli wrote: > On Fri, Nov 15, 2002 at 11:03:44AM -0600, mark tinguely wrote: > [snip] > > The memory is avaliable to the kernel/drivers when bus_dmamem_free() is > > called. The problem for you is that someone else does allocate a > > page within the 16 page chunk making it unable to reallocatable by you, > > so the next bus_dmamem_alloc() looks for the next 16 page contiguous > > chunk. This continues until there is no more 16 page contiguous chunks > > available and the bus_dmamem_alloc() fails. FreeBSD does not have a > > physical memory defragmenter. > > Ok, I get it now. Thanks to all for the explanation. Would a physical > defragmenter be of interest? I can't work on it right away, but if > there is interest, I could take a look at this later. I find it interesting, every time this issue comes up. The big problem, as I see it, is that it has to avoid things it already holds references to, so basically all code used in the defragmentation path has to be immune to defragmentation (very much like the Windows disk defragmentation, which can not move swap blocks, because part of the defragmenter itself might be swapped out to one of them). Really, there's a lot of the kernel which could be pageable, which would help this. But for this to work, all the code in the paging path has to be marked non-pageable. The way Windows handles this is to have seperate ELF sections for pageable vs. unpageable vs. init vs. other code/data. At present, FreeBSD only supports the concept of code, data, and BSS sections, so you would need to change the loader, if you wanted to do this. It's still possible to do wbithout kernel paging, but it will be a lot harder. All that said, I think people with clue would sing your praises from the rooftops if you did this; among other things, it would let code like video capture cards, which need huge contiguous areas, be loaded and unloaded and reloaded well after boot time (right now, if you don't load them at boot time, you are likely to be unable to load them at all, for lack of a large contiguous area of physical memory). Meanwhile, a common approach is to have a seperate patial driver to do the memory allocation on your behalf, and hold the references, but do nothing with them, so that you can load and unload the actual driver mechanics while you are developing the driver in the first place. Then you reference the memory allocated by the first driver from your module, instead of allocating and deallocating it each time. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message