From 39ff43c579870df6758757663432c4849c80d532 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 18 Nov 2013 16:58:55 +0100 Subject: [PATCH] * 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. --- ChangeLog | 6 ++++++ grub-core/kern/mm.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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; }