All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jay Zhou <jianjay.zhou@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, arei.gonglei@huawei.com,
	zhang.zhanghailiang@huawei.com, wangxinxin.wang@huawei.com,
	weidong.huang@huawei.com, xiaoguangrong@tencent.com,
	jdenemar@redhat.com, huangzhichao@huawei.com
Subject: Re: [Qemu-devel] [PATCH v2] migration: optimize the downtime
Date: Fri, 28 Jul 2017 14:25:55 +0800	[thread overview]
Message-ID: <597AD8F3.3020702@huawei.com> (raw)
In-Reply-To: <5c0789ef-9c29-b867-5e84-8624d04c16cc@redhat.com>

Hi Paolo,

On 2017/7/27 22:15, Paolo Bonzini wrote:
> On 27/07/2017 04:36, Jay Zhou wrote:
>> Qemu_savevm_state_cleanup takes about 300ms in my ram migration tests
>> with a 8U24G vm(20G is really occupied), the main cost comes from
>> KVM_SET_USER_MEMORY_REGION ioctl when mem.memory_size = 0 in
>> kvm_set_user_memory_region. In kmod, the main cost is
>> kvm_zap_obsolete_pages, which traverses the active_mmu_pages list to
>> zap the unsync sptes.
>>
>> It can be optimized by delaying memory_global_dirty_log_stop to the next
>> vm_start.
>>
>> Changes v1->v2:
>>   - create a VMChangeStateHandler in memory.c to reduce the coupling [Paolo]
>>
>> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
>
> memory_vm_change_state_handler should delete the handler.
>
> Apart from that, because there is no protection against nested
> invocations of memory_global_dirty_log_start/stop, a little more work is
> needed.

Thank for your patience and pointing everything out, I will fix all of them.

Jay

>> ---
>>   memory.c | 27 ++++++++++++++++++++++++++-
>>   1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/memory.c b/memory.c
>> index a7bc70a..4c22b7e 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -2357,8 +2357,14 @@ void memory_global_dirty_log_sync(void)
>>       }
>>   }
>>
>> +static VMChangeStateEntry *vmstate_change;
>> +
>>   void memory_global_dirty_log_start(void)
>>   {
>> +    if (vmstate_change) {
>> +        qemu_del_vm_change_state_handler(vmstate_change);
>
> This should also NULL vmstate_change, so that you can detect the case
> where the handler is already installed.
>
>> +    }
>> +
>>       global_dirty_log = true;
>>
>>       MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
>> @@ -2369,7 +2375,7 @@ void memory_global_dirty_log_start(void)
>>       memory_region_transaction_commit();
>>   }
>>
>> -void memory_global_dirty_log_stop(void)
>> +static void memory_global_dirty_log_do_stop(void)
>>   {
>>       global_dirty_log = false;
>>
>> @@ -2381,6 +2387,25 @@ void memory_global_dirty_log_stop(void)
>>       MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
>>   }
>>
>> +static void memory_vm_change_state_handler(void *opaque, int running,
>> +                                           RunState state)
>> +{
>> +    if (running) {
>> +        memory_global_dirty_log_do_stop();
>
> Because this will delete the handler, it should also NULL vmstate_change.
>
>> +    }
>> +}
>> +
>> +void memory_global_dirty_log_stop(void)
>> +{
>> +    if (!runstate_is_running()) {
>> +        vmstate_change = qemu_add_vm_change_state_handler(
>> +                                memory_vm_change_state_handler, NULL);
>
> And this needs to exit immediately if you have an installed handler.
>
> Thanks,
>
> Paolo
>
>> +        return;
>> +    }
>> +
>> +    memory_global_dirty_log_do_stop();
>> +}
>> +
>>   static void listener_add_address_space(MemoryListener *listener,
>>                                          AddressSpace *as)
>>   {
>>
>
>
> .
>

      reply	other threads:[~2017-07-28  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27  2:36 [Qemu-devel] [PATCH v2] migration: optimize the downtime Jay Zhou
2017-07-27 14:15 ` Paolo Bonzini
2017-07-28  6:25   ` Jay Zhou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=597AD8F3.3020702@huawei.com \
    --to=jianjay.zhou@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=huangzhichao@huawei.com \
    --cc=jdenemar@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wangxinxin.wang@huawei.com \
    --cc=weidong.huang@huawei.com \
    --cc=xiaoguangrong@tencent.com \
    --cc=zhang.zhanghailiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.