From: Vladimir Serbinenko Date: Mon, 18 Nov 2013 15:58:55 +0000 (+0100) Subject: * grub-core/kern/mm.c (grub_real_malloc): Don't update the pointer to X-Git-Tag: grub-2.02-beta1~268 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39ff43c579870df6758757663432c4849c80d532;p=thirdparty%2Fgrub.git * grub-core/kern/mm.c (grub_real_malloc): Don't update the pointer to current memory when allocating large chunks. This significantly decreases memory fragmentation. --- diff --git a/ChangeLog b/ChangeLog index aa39cb968..ba6af6af6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-11-18 Vladimir Serbinenko + + * grub-core/kern/mm.c (grub_real_malloc): Don't update the pointer to + current memory when allocating large chunks. This significantly + decreases memory fragmentation. + 2013-11-18 Colin Watson * util/grub-mkrescue.c (main): Fix typo. diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 6111eef7e..53f3475f5 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -298,7 +298,10 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) /* Mark find as a start marker for next allocation to fasten it. This will have side effect of fragmenting memory as small pieces before this will be un-used. */ - *first = q; + /* So do it only for chunks under 64K. */ + if (n < (0x10000 >> GRUB_MM_ALIGN_LOG2) + || *first == p) + *first = q; return p + 1; }