From 68de4f1434a46df7d1b6e59cb348f11c92dbf17c Mon Sep 17 00:00:00 2001 Message-Id: <68de4f1434a46df7d1b6e59cb348f11c92dbf17c.1380723420.git.minovotn@redhat.com> From: Markus Armbruster Date: Tue, 1 Oct 2013 08:12:02 +0200 Subject: [PATCH 01/13] exec: Simplify allocation of guest RAM RH-Author: Markus Armbruster Message-id: <1380615123-24391-2-git-send-email-armbru@redhat.com> Patchwork-id: 54611 O-Subject: [PATCH 6.5 qemu-kvm v2 1/2] exec: Simplify allocation of guest RAM Bugzilla: 867921 RH-Acked-by: Paolo Bonzini RH-Acked-by: Eduardo Habkost RH-Acked-by: Igor Mammedov From: Markus Armbruster Upstream commit 858f3fd and commit c2a823 (RHEL-6 commit 1db30b4) both optimized reviewability, but now the result is a bit of a mess. The mess gets in the way of reporting out of memory conditions there nicely, so replace it by a simpler mess: inline qemu_vmalloc(), drop code for systems other than __linux && __x86_64__, drop the tracing, then simplify. Signed-off-by: Markus Armbruster --- exec.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) Signed-off-by: Michal Novotny --- exec.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/exec.c b/exec.c index df5a98b..2f43733 100644 --- a/exec.c +++ b/exec.c @@ -2764,15 +2764,12 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); #else + size_t align = getpagesize(); #ifdef PREFERRED_RAM_ALIGN - if (size >= PREFERRED_RAM_ALIGN) - if (running_on_valgrind) - new_block->host = qemu_vmalloc(size); - else - new_block->host = qemu_memalign(PREFERRED_RAM_ALIGN, size); - else -#endif - new_block->host = qemu_vmalloc(size); + if (size >= PREFERRED_RAM_ALIGN && !running_on_valgrind) + align = PREFERRED_RAM_ALIGN; +#endif + new_block->host = qemu_memalign(align, size); #endif #ifdef MADV_MERGEABLE if (!disable_KSM) -- 1.7.11.7