Re: ZONE_DMA

Christoph Lameter
2006-09-22T02:59:15Z

On Thu, 21 Sep 2006, Martin Bligh wrote:

> Just ignoring GFP_DMA in the allocator seems like a horrible violation
> to me. GFP_DMA means "give me memory from ZONE_DMA". We're both well
> aware that the whole concept of ZONE_DMA doesn't make much sense, but
> still, that's what it does.

We agreed that the definition of ZONE_DMA is not consistent across
architectures.

The concept of ZONE_DMA makes only sense in terms of an architectures
definition if a memory boundary (MAX_DMA_ADDRESS) exists for special DMA
devices not able to reach all of memory. If we do not have ZONE_DMA then the
architecture has to remove the definition of CONFIG_ZONE_DMA
and with that action told us that it is allowable to ignore GFP_DMA since
all devices can do DMA to all of memory (and all of memory is memory
without a border which is of course in ZONE_NORMAL).

GFP_DMA like GFP_HIGHMEM and GFP_DMA32 means give me memory from the zone
if its there. If not (the arch has no such memory) we fall back to ZONE_NORMAL.

This is fully consistent with established uses.

> So if you just put all of memory in ZONE_DMA for your particular
> machine, and bumped the DMA limit up to infinity, we wouldn't need
> any of these patches, right? Which would also match what the other
> arches do for this (eg PPC64).

That would mean abusing ZONE_DMA for a purpose it was not intended for.
ZOME_DMA is used to partition memory for a DMA not for covering all of
memory. That works yes but it shows a misunderstanding of the purpose for
which ZONE_DMA was created.

Also if you would do that then ZONE_NORMAL would be empty and you would
not be able to reach the goal of a system with a single zone. The slab
allocator gets thoroughly confused and waste pages allocating
memory in different slabs for ZONE_NORMAL and ZONE_DMA but they end up in
the same ZONE_DMA. Various other bits and pieces of the VM behave in
strange way but it works mostly. Seems that you got lucky but this should
be fixed.

ZONE_NORMAL is DMAable. GFP_DMA has never meant this is for DMA but it has
always meant this is for a special restricted DMA zone. That is also why
you have GFP_DMA32. Both GFP_DMA and GFP_DMA32 select special restricted
memory areas for handicapped DMA devices that are not able to reach all of
memory. Neither should cover all of memory.