Hi,

attached patch changes the preallocation scheme in memalign from
"100 elements of the size of the size of the alignment, except if the
user requested more" to
"nearly 1kb worth of elements, except if the user requested more".

This should help with certain crash situations related to requesting 4kb
aligned memory (which tries to allocate 400kb), and still works towards
the purpose of this feature, namely optimizing the (not so rare) case of
lots of small allocations of small alignments.

Signed-off-by: Patrick Georgi <[email protected]>
Index: libc/malloc.c
===================================================================
--- libc/malloc.c       (revision 5036)
+++ libc/malloc.c       (working copy)
@@ -331,7 +331,7 @@
        }
        if (reg == 0)
        {
-               align_regions = allocate_region(align_regions, align, 
(size/align<99)?100:((size/align)+1));
+               align_regions = allocate_region(align_regions, align, 
(size<1024)?(1024/align):((size-1/align)+1));
                reg = align_regions;
        }
        int i, count = 0, target = (size+align-1)/align;
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to