|
|
9ae3a8 |
From 38dcbd1ff68da81b9172d8036622e41fe591c5c0 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Andrea Arcangeli <aarcange@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 7 Feb 2014 11:02:33 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 10/28] exec: always use MADV_DONTFORK
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Andrea Arcangeli <aarcange@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1391770953-20138-2-git-send-email-aarcange@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 57131
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH] exec: always use MADV_DONTFORK
|
|
|
9ae3a8 |
Bugzilla: 1004197
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Andrew Jones <drjones@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
|
|
|
9ae3a8 |
overcommit heuristics decides there's too much anonymous virtual
|
|
|
9ae3a8 |
memory allocated. If the KVM secondary MMU is synchronized with MMU
|
|
|
9ae3a8 |
notifiers or not, doesn't make a difference in that regard.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Secondly it's always more efficient to avoid copying the guest
|
|
|
9ae3a8 |
physical address space in the fork child (so we avoid to mark all the
|
|
|
9ae3a8 |
guest memory readonly in the parent and so we skip the establishment
|
|
|
9ae3a8 |
and teardown of lots of pagetables in the child).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In the common case we can ignore the error if MADV_DONTFORK is not
|
|
|
9ae3a8 |
available. Leave a second invocation that errors out in the KVM path
|
|
|
9ae3a8 |
if MMU notifiers are missing and KVM is enabled, to abort in such
|
|
|
9ae3a8 |
case.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
|
|
|
9ae3a8 |
Tested-By: Benoit Canet <benoit@irqsave.net>
|
|
|
9ae3a8 |
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gleb Natapov <gleb@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from upstream commit 3e469dbfe413c25d48321c3a19ddfae0727dc6e5)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 1 +
|
|
|
9ae3a8 |
1 file changed, 1 insertion(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 1 +
|
|
|
9ae3a8 |
1 files changed, 1 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/exec.c b/exec.c
|
|
|
9ae3a8 |
index ce9310c..6fe2fe7 100644
|
|
|
9ae3a8 |
--- a/exec.c
|
|
|
9ae3a8 |
+++ b/exec.c
|
|
|
9ae3a8 |
@@ -1194,6 +1194,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu_ram_setup_dump(new_block->host, size);
|
|
|
9ae3a8 |
qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
|
|
|
9ae3a8 |
+ qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (kvm_enabled())
|
|
|
9ae3a8 |
kvm_setup_guest_memory(new_block->host, size);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|