Re: Bugs and wishes in memory management area

Jon Tombs (
Thu, 21 Nov 1996 16:41:27 +0100 (MET)

Rob Riggs said:

> This would seem to imply that one can do:
> ptr = kmalloc(size, GFP_DMA | GFP_KERNEL);
> The comments in mm.h clearly state that "GFP_DMA" is a flag, not an
> actual priority level. However GFP_DMA & GFP_LEVEL_MASK = GFP_BUFFER.
> And GFP_BUFFER does not try very hard to free pages.

Yes you can do it, but it doesn't help. The problem is in get_free_pages, it
returns when there is enough free pages, or if called with the ATOMIC flag.
But it doesn't check if the free pages are actually suitable for the DMA
request. You can fix it easily with an extra if() that avoids returning NULL
when called (GFP_DMA | GFP_KERNEL), but this just results in randomly freeing
pages until success.

What is really needed is an algorithm to pick the pages, or you will swap
several MB in order to create a single 128k DMA buffer (I know, I've

Jon. <,>