Subject: Re: 1.6.2 kernel: ex driver sometimes can't allocate
To: None <tech-kern@NetBSD.org>
From: Chapman Flack <email@example.com>
Date: 09/19/2004 13:30:07
Manuel Bouyer wrote:
> This is because of the BUS_DMA_NOWAIT flag passed to bus_dmamem_alloc().
> There may be no pages free at this time, and we explicitely tell bus_dma
> that we can't wait for some to be available.
und Jochen Kunz wrote:
> bus_dmamem_alloc(9) allocates a chunk of _continuous_pysical_ memory for
> DMA. If a loaded system is running for some time ... [memory is too
> fragmented]. ... Fragmentation is no problem for a process.... But DMA
> operates on pysical adresses without involveing the MMU, thus the
> requirement of continuous pysical memory.
I understand both explanations. And yet, this behavior could best be called
flaky and it does nothing to evangelize NetBSD in a roomful of people who can
plug their cards into their computers and the drivers attach and they work.
"Wait, wait! See, if I just type this dd command first ...."
Does our memory manager support some kind of advance reservation: the kernel
may be needing N kB of contiguous memory at some later time, please avoid
fragmentation in that region? The reserved memory doesn't have to be wasted;
the memory manager might freely use it to map text or other readonly pages
in the meantime, just nothing writable or locked, so nothing can be dirty and
if the contiguous memory is called for later, it can be immediately reclaimed
just by invalidating the pages and nothing needs to be flushed.
If our memory manager can't currently do something like that, is there any
reason it would not be a good idea?
> > Would it work better if I explicitly config ex0 and ex1,
> > instead of clone ex* ?
> no, it wouldn't change anything.
Ah, but maybe in an improved design it would. If a driver can predict that
it will need to allocate N kB of memory on attach with certain properties
(contiguous, in a certain address range, etc.)--and who would know that
better than the driver?--and autoconfiguration has an explicit count of
how many instances there might be, it might be reasonable to have a hook
in autoconfig that could place reservations on the space as I sketched out
In the short term, what happens if BUS_DMA_NOWAIT isn't passed in this
particular call? Does that allow the memory manager to do some reclamation?
Is the BUS_DMA_NOWAIT required because of a possible deadlock?