All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
@ 2013-07-25 10:11 Andrea Arcangeli
  2013-07-25 10:16 ` Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Andrea Arcangeli @ 2013-07-25 10:11 UTC (permalink / raw)
  To: qemu-devel, qemu-stable; +Cc: Paolo Bonzini, Gleb Natapov

MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
overcommit heuristics decides there's too much anonymous virtual
memory allocated. If the KVM secondary MMU is synchronized with MMU
notifiers or not, doesn't make a difference in that regard.

Secondly it's always more efficient to avoid copying the guest
physical address space in the fork child (so we avoid to mark all the
guest memory readonly in the parent and so we skip the establishment
and teardown of lots of pagetables in the child).

In the common case we can ignore the error if MADV_DONTFORK is not
available. Leave a second invocation that errors out in the KVM path
if MMU notifiers are missing and KVM is enabled, to abort in such
case.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
 exec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/exec.c b/exec.c
index c99a883..d3bb58d 100644
--- a/exec.c
+++ b/exec.c
@@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
 
     qemu_ram_setup_dump(new_block->host, size);
     qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
+    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
 
     if (kvm_enabled())
         kvm_setup_guest_memory(new_block->host, size);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
@ 2013-07-25 10:16 ` Peter Maydell
  2013-07-25 10:32   ` Andrea Arcangeli
  2013-08-06 16:47 ` [Qemu-devel] PING for-1.6 " Paolo Bonzini
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Peter Maydell @ 2013-07-25 10:16 UTC (permalink / raw)
  To: Andrea Arcangeli; +Cc: Paolo Bonzini, qemu-devel, Gleb Natapov, qemu-stable

On 25 July 2013 11:11, Andrea Arcangeli <aarcange@redhat.com> wrote:
> diff --git a/exec.c b/exec.c
> index c99a883..d3bb58d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>
>      qemu_ram_setup_dump(new_block->host, size);
>      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>
>      if (kvm_enabled())
>          kvm_setup_guest_memory(new_block->host, size);
>

kvm_setup_guest_memory() already calls
  qemu_madvise(start, size, QEMU_MADV_DONTFORK)
so why do we need to do it here as well?
If we should be doing it in all cases presumably the right
fix is to move the if (!kvm_has_sync_mmu()) check in
kvm_setup_guest_memory() from "do we call madvise" to
"do we fail with an error if it failed".

thanks
-- PMM

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:16 ` Peter Maydell
@ 2013-07-25 10:32   ` Andrea Arcangeli
  2013-08-06 16:55     ` Andreas Färber
  0 siblings, 1 reply; 13+ messages in thread
From: Andrea Arcangeli @ 2013-07-25 10:32 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel, Gleb Natapov, qemu-stable

On Thu, Jul 25, 2013 at 11:16:44AM +0100, Peter Maydell wrote:
> On 25 July 2013 11:11, Andrea Arcangeli <aarcange@redhat.com> wrote:
> > diff --git a/exec.c b/exec.c
> > index c99a883..d3bb58d 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
> >
> >      qemu_ram_setup_dump(new_block->host, size);
> >      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
> > +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
> >
> >      if (kvm_enabled())
> >          kvm_setup_guest_memory(new_block->host, size);
> >
> 
> kvm_setup_guest_memory() already calls
>   qemu_madvise(start, size, QEMU_MADV_DONTFORK)
> so why do we need to do it here as well?

That only runs if kvm is enabled and mmu is not sync. But we need it
in the common case too, to prevent -ENOMEM (if MADV_DONTFORK is
available in the host OS, otherwise well we'll just do best effort and
skip). See commit message for more details.

> If we should be doing it in all cases presumably the right
> fix is to move the if (!kvm_has_sync_mmu()) check in
> kvm_setup_guest_memory() from "do we call madvise" to
> "do we fail with an error if it failed".

We could pass an error to kvm_setup_guest_memory but it's not worth it
considering more likely we should abort if kvm is enabled and mmu is
not sync (without bothering to call MADV_DONTFORK there).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] PING for-1.6 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
  2013-07-25 10:16 ` Peter Maydell
@ 2013-08-06 16:47 ` Paolo Bonzini
  2013-08-30 15:48   ` [Qemu-devel] PING^2 " Paolo Bonzini
  2013-08-06 17:06 ` [Qemu-devel] " Benoît Canet
  2013-09-01  9:39 ` Gleb Natapov
  3 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2013-08-06 16:47 UTC (permalink / raw)
  To: Andrea Arcangeli; +Cc: qemu-devel, Gleb Natapov, qemu-stable

On 07/25/2013 12:11 PM, Andrea Arcangeli wrote:
> MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
> overcommit heuristics decides there's too much anonymous virtual
> memory allocated. If the KVM secondary MMU is synchronized with MMU
> notifiers or not, doesn't make a difference in that regard.
>
> Secondly it's always more efficient to avoid copying the guest
> physical address space in the fork child (so we avoid to mark all the
> guest memory readonly in the parent and so we skip the establishment
> and teardown of lots of pagetables in the child).
>
> In the common case we can ignore the error if MADV_DONTFORK is not
> available. Leave a second invocation that errors out in the KVM path
> if MMU notifiers are missing and KVM is enabled, to abort in such
> case.
>
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> ---
>   exec.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/exec.c b/exec.c
> index c99a883..d3bb58d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>
>       qemu_ram_setup_dump(new_block->host, size);
>       qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>
>       if (kvm_enabled())
>           kvm_setup_guest_memory(new_block->host, size);
>
>

PING.

Benoit reported this on IRC, too.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:32   ` Andrea Arcangeli
@ 2013-08-06 16:55     ` Andreas Färber
  2013-08-30 15:48       ` Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-08-06 16:55 UTC (permalink / raw)
  To: Andrea Arcangeli, Paolo Bonzini
  Cc: Peter Maydell, qemu-devel, Gleb Natapov, qemu-stable

Am 25.07.2013 12:32, schrieb Andrea Arcangeli:
> On Thu, Jul 25, 2013 at 11:16:44AM +0100, Peter Maydell wrote:
>> On 25 July 2013 11:11, Andrea Arcangeli <aarcange@redhat.com> wrote:
>>> diff --git a/exec.c b/exec.c
>>> index c99a883..d3bb58d 100644
>>> --- a/exec.c
>>> +++ b/exec.c
>>> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>>>
>>>      qemu_ram_setup_dump(new_block->host, size);
>>>      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
>>> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>>>
>>>      if (kvm_enabled())
>>>          kvm_setup_guest_memory(new_block->host, size);
>>>
>>
>> kvm_setup_guest_memory() already calls
>>   qemu_madvise(start, size, QEMU_MADV_DONTFORK)
>> so why do we need to do it here as well?
> 
> That only runs if kvm is enabled and mmu is not sync. But we need it
> in the common case too, to prevent -ENOMEM (if MADV_DONTFORK is
> available in the host OS, otherwise well we'll just do best effort and
> skip). See commit message for more details.

So if we add the DONTFORK unconditionally here, why not drop it in said
kvm_setup_guest_memory()? That would make the patch more
self-documenting while at it.

Andreas

> 
>> If we should be doing it in all cases presumably the right
>> fix is to move the if (!kvm_has_sync_mmu()) check in
>> kvm_setup_guest_memory() from "do we call madvise" to
>> "do we fail with an error if it failed".
> 
> We could pass an error to kvm_setup_guest_memory but it's not worth it
> considering more likely we should abort if kvm is enabled and mmu is
> not sync (without bothering to call MADV_DONTFORK there).
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
  2013-07-25 10:16 ` Peter Maydell
  2013-08-06 16:47 ` [Qemu-devel] PING for-1.6 " Paolo Bonzini
@ 2013-08-06 17:06 ` Benoît Canet
  2013-09-01  9:39 ` Gleb Natapov
  3 siblings, 0 replies; 13+ messages in thread
From: Benoît Canet @ 2013-08-06 17:06 UTC (permalink / raw)
  To: Andrea Arcangeli; +Cc: Paolo Bonzini, qemu-devel, Gleb Natapov, qemu-stable

Le Thursday 25 Jul 2013 à 12:11:15 (+0200), Andrea Arcangeli a écrit :
> MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
> overcommit heuristics decides there's too much anonymous virtual
> memory allocated. If the KVM secondary MMU is synchronized with MMU
> notifiers or not, doesn't make a difference in that regard.
> 
> Secondly it's always more efficient to avoid copying the guest
> physical address space in the fork child (so we avoid to mark all the
> guest memory readonly in the parent and so we skip the establishment
> and teardown of lots of pagetables in the child).
> 
> In the common case we can ignore the error if MADV_DONTFORK is not
> available. Leave a second invocation that errors out in the KVM path
> if MMU notifiers are missing and KVM is enabled, to abort in such
> case.
> 
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> ---
>  exec.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/exec.c b/exec.c
> index c99a883..d3bb58d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>  
>      qemu_ram_setup_dump(new_block->host, size);
>      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>  
>      if (kvm_enabled())
>          kvm_setup_guest_memory(new_block->host, size);
> 

This patch solve a bug where the network down script of a regular tap interface
is not executed because fork fail when a pci-assigment is done on a large guest.

Tested-By: Benoit Canet <benoit@irqsave.net>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] PING^2 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-08-06 16:47 ` [Qemu-devel] PING for-1.6 " Paolo Bonzini
@ 2013-08-30 15:48   ` Paolo Bonzini
  2013-08-30 15:52     ` Andreas Färber
  0 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2013-08-30 15:48 UTC (permalink / raw)
  Cc: Andrea Arcangeli, qemu-devel, Gleb Natapov, qemu-stable

Il 06/08/2013 18:47, Paolo Bonzini ha scritto:
> On 07/25/2013 12:11 PM, Andrea Arcangeli wrote:
>> MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
>> overcommit heuristics decides there's too much anonymous virtual
>> memory allocated. If the KVM secondary MMU is synchronized with MMU
>> notifiers or not, doesn't make a difference in that regard.
>>
>> Secondly it's always more efficient to avoid copying the guest
>> physical address space in the fork child (so we avoid to mark all the
>> guest memory readonly in the parent and so we skip the establishment
>> and teardown of lots of pagetables in the child).
>>
>> In the common case we can ignore the error if MADV_DONTFORK is not
>> available. Leave a second invocation that errors out in the KVM path
>> if MMU notifiers are missing and KVM is enabled, to abort in such
>> case.
>>
>> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>> ---
>>   exec.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/exec.c b/exec.c
>> index c99a883..d3bb58d 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t
>> size, void *host,
>>
>>       qemu_ram_setup_dump(new_block->host, size);
>>       qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
>> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>>
>>       if (kvm_enabled())
>>           kvm_setup_guest_memory(new_block->host, size);
>>
>>
> 
> PING.
> 
> Benoit reported this on IRC, too.
> 
> Paolo
> 
> 

PING^2

The last paragraph of the commit message should answer Andreas's objection.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-08-06 16:55     ` Andreas Färber
@ 2013-08-30 15:48       ` Paolo Bonzini
  0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2013-08-30 15:48 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Andrea Arcangeli, Peter Maydell, qemu-devel, Gleb Natapov, qemu-stable

Il 06/08/2013 18:55, Andreas Färber ha scritto:
> Am 25.07.2013 12:32, schrieb Andrea Arcangeli:
>> On Thu, Jul 25, 2013 at 11:16:44AM +0100, Peter Maydell wrote:
>>> On 25 July 2013 11:11, Andrea Arcangeli <aarcange@redhat.com> wrote:
>>>> diff --git a/exec.c b/exec.c
>>>> index c99a883..d3bb58d 100644
>>>> --- a/exec.c
>>>> +++ b/exec.c
>>>> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>>>>
>>>>      qemu_ram_setup_dump(new_block->host, size);
>>>>      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
>>>> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>>>>
>>>>      if (kvm_enabled())
>>>>          kvm_setup_guest_memory(new_block->host, size);
>>>>
>>>
>>> kvm_setup_guest_memory() already calls
>>>   qemu_madvise(start, size, QEMU_MADV_DONTFORK)
>>> so why do we need to do it here as well?
>>
>> That only runs if kvm is enabled and mmu is not sync. But we need it
>> in the common case too, to prevent -ENOMEM (if MADV_DONTFORK is
>> available in the host OS, otherwise well we'll just do best effort and
>> skip). See commit message for more details.
> 
> So if we add the DONTFORK unconditionally here, why not drop it in said
> kvm_setup_guest_memory()? That would make the patch more
> self-documenting while at it.

This is mentioned in the commit message:

"In the common case we can ignore the error if MADV_DONTFORK is not
available. Leave a second invocation that errors out in the KVM path if
MMU notifiers are missing and KVM is enabled, to abort in such case".

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] PING^2 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-08-30 15:48   ` [Qemu-devel] PING^2 " Paolo Bonzini
@ 2013-08-30 15:52     ` Andreas Färber
  2013-08-30 16:03       ` Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-08-30 15:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Andrea Arcangeli, qemu-devel, Gleb Natapov, qemu-stable

Am 30.08.2013 17:48, schrieb Paolo Bonzini:
> Il 06/08/2013 18:47, Paolo Bonzini ha scritto:
>> On 07/25/2013 12:11 PM, Andrea Arcangeli wrote:
>>> MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
>>> overcommit heuristics decides there's too much anonymous virtual
>>> memory allocated. If the KVM secondary MMU is synchronized with MMU
>>> notifiers or not, doesn't make a difference in that regard.
>>>
>>> Secondly it's always more efficient to avoid copying the guest
>>> physical address space in the fork child (so we avoid to mark all the
>>> guest memory readonly in the parent and so we skip the establishment
>>> and teardown of lots of pagetables in the child).
>>>
>>> In the common case we can ignore the error if MADV_DONTFORK is not
>>> available. Leave a second invocation that errors out in the KVM path
>>> if MMU notifiers are missing and KVM is enabled, to abort in such
>>> case.
>>>
>>> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>>> ---
>>>   exec.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/exec.c b/exec.c
>>> index c99a883..d3bb58d 100644
>>> --- a/exec.c
>>> +++ b/exec.c
>>> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t
>>> size, void *host,
>>>
>>>       qemu_ram_setup_dump(new_block->host, size);
>>>       qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
>>> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>>>
>>>       if (kvm_enabled())
>>>           kvm_setup_guest_memory(new_block->host, size);
>>>
>>>
>>
>> PING.
>>
>> Benoit reported this on IRC, too.
>>
>> Paolo
>>
>>
> 
> PING^2
> 
> The last paragraph of the commit message should answer Andreas's objection.

OK. The patch is mislabelled as "KVM:" though putting this in a common
code path and touching exec.c only, so please put it on uq/master and
fix that up before you set the history in stone. :)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] PING^2 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-08-30 15:52     ` Andreas Färber
@ 2013-08-30 16:03       ` Paolo Bonzini
  2013-08-30 16:21         ` Gleb Natapov
  0 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2013-08-30 16:03 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Andrea Arcangeli, qemu-devel, Gleb Natapov, qemu-stable

Il 30/08/2013 17:52, Andreas Färber ha scritto:
> OK. The patch is mislabelled as "KVM:" though putting this in a common
> code path and touching exec.c only, so please put it on uq/master and
> fix that up before you set the history in stone. :)

Well, touching exec.c is why I wasn't picking it up through uq/master,
but that's indeed a good observation!

If Anthony doesn't pick it up, I'll do so as soon as it's my turn to
manage the qemu-kvm.git repository.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] PING^2 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-08-30 16:03       ` Paolo Bonzini
@ 2013-08-30 16:21         ` Gleb Natapov
  2013-08-30 16:40           ` Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: Gleb Natapov @ 2013-08-30 16:21 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Andrea Arcangeli, qemu-stable, Andreas Färber, qemu-devel

On Fri, Aug 30, 2013 at 06:03:42PM +0200, Paolo Bonzini wrote:
> Il 30/08/2013 17:52, Andreas Färber ha scritto:
> > OK. The patch is mislabelled as "KVM:" though putting this in a common
> > code path and touching exec.c only, so please put it on uq/master and
> > fix that up before you set the history in stone. :)
> 
> Well, touching exec.c is why I wasn't picking it up through uq/master,
> but that's indeed a good observation!
> 
> If Anthony doesn't pick it up, I'll do so as soon as it's my turn to
> manage the qemu-kvm.git repository.
> 
Send your acks and I will merge it.

--
			Gleb.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] PING^2 Re: [PATCH] KVM: always use MADV_DONTFORK
  2013-08-30 16:21         ` Gleb Natapov
@ 2013-08-30 16:40           ` Paolo Bonzini
  0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2013-08-30 16:40 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: Andrea Arcangeli, qemu-stable, Andreas Färber, qemu-devel

Il 30/08/2013 18:21, Gleb Natapov ha scritto:
> On Fri, Aug 30, 2013 at 06:03:42PM +0200, Paolo Bonzini wrote:
>> Il 30/08/2013 17:52, Andreas Färber ha scritto:
>>> OK. The patch is mislabelled as "KVM:" though putting this in a common
>>> code path and touching exec.c only, so please put it on uq/master and
>>> fix that up before you set the history in stone. :)
>>
>> Well, touching exec.c is why I wasn't picking it up through uq/master,
>> but that's indeed a good observation!
>>
>> If Anthony doesn't pick it up, I'll do so as soon as it's my turn to
>> manage the qemu-kvm.git repository.
>>
> Send your acks and I will merge it.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

with s/KVM/exec/ in the subject line

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
  2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
                   ` (2 preceding siblings ...)
  2013-08-06 17:06 ` [Qemu-devel] " Benoît Canet
@ 2013-09-01  9:39 ` Gleb Natapov
  3 siblings, 0 replies; 13+ messages in thread
From: Gleb Natapov @ 2013-09-01  9:39 UTC (permalink / raw)
  To: Andrea Arcangeli; +Cc: Paolo Bonzini, qemu-devel, qemu-stable

On Thu, Jul 25, 2013 at 12:11:15PM +0200, Andrea Arcangeli wrote:
> MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
> overcommit heuristics decides there's too much anonymous virtual
> memory allocated. If the KVM secondary MMU is synchronized with MMU
> notifiers or not, doesn't make a difference in that regard.
> 
> Secondly it's always more efficient to avoid copying the guest
> physical address space in the fork child (so we avoid to mark all the
> guest memory readonly in the parent and so we skip the establishment
> and teardown of lots of pagetables in the child).
> 
> In the common case we can ignore the error if MADV_DONTFORK is not
> available. Leave a second invocation that errors out in the KVM path
> if MMU notifiers are missing and KVM is enabled, to abort in such
> case.
> 
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Applied to uq/master, thanks.

> ---
>  exec.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/exec.c b/exec.c
> index c99a883..d3bb58d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
>  
>      qemu_ram_setup_dump(new_block->host, size);
>      qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
> +    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
>  
>      if (kvm_enabled())
>          kvm_setup_guest_memory(new_block->host, size);

--
			Gleb.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-09-01  9:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
2013-07-25 10:16 ` Peter Maydell
2013-07-25 10:32   ` Andrea Arcangeli
2013-08-06 16:55     ` Andreas Färber
2013-08-30 15:48       ` Paolo Bonzini
2013-08-06 16:47 ` [Qemu-devel] PING for-1.6 " Paolo Bonzini
2013-08-30 15:48   ` [Qemu-devel] PING^2 " Paolo Bonzini
2013-08-30 15:52     ` Andreas Färber
2013-08-30 16:03       ` Paolo Bonzini
2013-08-30 16:21         ` Gleb Natapov
2013-08-30 16:40           ` Paolo Bonzini
2013-08-06 17:06 ` [Qemu-devel] " Benoît Canet
2013-09-01  9:39 ` Gleb Natapov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.