Messages in this thread Patch in this message | | | From | (Marek Michalkiewicz) | Subject | Problem with >1 page GFP_KERNEL kmalloc() | Date | Sat, 29 Mar 1997 21:45:35 +0100 (MET) |
| |
Hi,
some time ago I wrote a small kernel patch to fix a bug with kmalloc() failing to allocate large memory blocks (>1 page). I sent this patch to the linux-kernel list, and it's on the "unofficial Linux 2.0 patches" web page (http://www.ecsnet.com/html/linux_upatch.html), but I haven't received any feedback on it so far.
The patch is very small so I'm including it here. Please try it and tell me if you see any problems with it. If there are none, would it be possible to include it in 2.0.30?
The problem the patch is trying to address is that we don't try hard enough to free some pages - if (nr_free_pages > reserved_pages), GFP_KERNEL is effectively the same as GFP_ATOMIC. But we may have enough free pages, just not in a single contiguous physical memory block. So, we should try to free more pages until we either succeed (allocate the block) or can't free any more pages.
There are certainly better ways to do it (currently it just tries to free random pages until it succeeds) but still I think it is better than nothing. ftape DMA buffers, resizing to large screens in SVGATextMode, etc. should benefit from it. While there may be a better fix in 2.1.x, this one should be good enough for 2.0.x.
Regards,
Marek
--- linux/mm/page_alloc.c.orig Sat Aug 17 20:19:29 1996 +++ linux/mm/page_alloc.c Sat Jan 11 05:44:58 1997 @@ -210,11 +210,10 @@ cli(); if ((priority==GFP_ATOMIC) || nr_free_pages > reserved_pages) { RMQUEUE(order, dma); - restore_flags(flags); - return 0; } restore_flags(flags); - if (priority != GFP_BUFFER && try_to_free_page(priority, dma, 1)) + if (priority != GFP_ATOMIC && priority != GFP_BUFFER && + try_to_free_page(priority, dma, 1)) goto repeat; return 0; }
| |