Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757340AbcCDCnz (ORCPT ); Thu, 3 Mar 2016 21:43:55 -0500 Received: from mga04.intel.com ([192.55.52.120]:14762 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755617AbcCDCny (ORCPT ); Thu, 3 Mar 2016 21:43:54 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,534,1449561600"; d="scan'208";a="663549187" From: "Li, Liang Z" To: "Daniel P. Berrange" CC: "quintela@redhat.com" , "amit.shah@redhat.com" , "qemu-devel@nongnu.org" , "linux-kernel@vger.kernel.org" , "ehabkost@redhat.com" , "kvm@vger.kernel.org" , "mst@redhat.com" , "dgilbert@redhat.com" , "virtualization@lists.linux-foundation.org" , "linux-mm@kvack.org" , "pbonzini@redhat.com" , "akpm@linux-foundation.org" , "rth@twiddle.net" Subject: RE: [Qemu-devel] [RFC qemu 4/4] migration: filter out guest's free pages in ram bulk stage Thread-Topic: [Qemu-devel] [RFC qemu 4/4] migration: filter out guest's free pages in ram bulk stage Thread-Index: AQHRdTqQQsFM+srMq0e7r7ok87aiJ59HJIUAgAFvjyA= Date: Fri, 4 Mar 2016 02:43:49 +0000 Message-ID: References: <1457001868-15949-1-git-send-email-liang.z.li@intel.com> <1457001868-15949-5-git-send-email-liang.z.li@intel.com> <20160303124520.GE32270@redhat.com> In-Reply-To: <20160303124520.GE32270@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzZhNjY5NGYtZTIxMi00OTU4LTllYTctODgwYjc0OTVmZjg5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Imx4d0dGZU1YaGVEN29wQWlmeWdOYWY5a2x2elJwNFo2SlR1SHFlT25ySkk9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u242i6Yo028088 Content-Length: 1873 Lines: 48 > On Thu, Mar 03, 2016 at 06:44:28PM +0800, Liang Li wrote: > > Get the free pages information through virtio and filter out the free > > pages in the ram bulk stage. This can significantly reduce the total > > live migration time as well as network traffic. > > > > Signed-off-by: Liang Li > > --- > > migration/ram.c | 52 > > ++++++++++++++++++++++++++++++++++++++++++++++------ > > 1 file changed, 46 insertions(+), 6 deletions(-) > > > @@ -1945,6 +1971,20 @@ static int ram_save_setup(QEMUFile *f, void > *opaque) > > DIRTY_MEMORY_MIGRATION); > > } > > memory_global_dirty_log_start(); > > + > > + if (balloon_free_pages_support() && > > + balloon_get_free_pages(migration_bitmap_rcu->free_pages_bmap, > > + &free_pages_count) == 0) { > > + qemu_mutex_unlock_iothread(); > > + while (balloon_get_free_pages(migration_bitmap_rcu- > >free_pages_bmap, > > + &free_pages_count) == 0) { > > + usleep(1000); > > + } > > + qemu_mutex_lock_iothread(); > > + > > + filter_out_guest_free_pages(migration_bitmap_rcu- > >free_pages_bmap); > > + } > > IIUC, this code is synchronous wrt to the guest OS balloon drive. ie it is asking > the geust for free pages and waiting for a response. If the guest OS has > crashed this is going to mean QEMU waits forever and thus migration won't > complete. Similarly you need to consider that the guest OS may be malicious > and simply never respond. > > So if the migration code is going to use the guest balloon driver to get info > about free pages it has to be done in an asynchronous manner so that > migration can never be stalled by a slow/crashed/malicious guest driver. > > Regards, > Daniel Really, thanks a lot! Liang