From patchwork Tue Sep 19 18:06:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jennifer Herbert X-Patchwork-Id: 9959919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C50160568 for ; Tue, 19 Sep 2017 18:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B00428C1C for ; Tue, 19 Sep 2017 18:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FE7D28E7E; Tue, 19 Sep 2017 18:16:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A426B28D74 for ; Tue, 19 Sep 2017 18:16:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duN1w-0007b2-2M; Tue, 19 Sep 2017 18:13:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duN1v-0007aL-0f for xen-devel@lists.xenproject.org; Tue, 19 Sep 2017 18:13:55 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 4D/D2-03283-26E51C95; Tue, 19 Sep 2017 18:13:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrohUjch7mC kwYX9Fhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8afZy/YCtqlKq4dTWtgbBHtYuTkkBDwl1i1 cxJ7FyMHB5uAicSbB6FdjFwcIgItjBKLT+0CizMLGEm0HeUGKRcWcJXYeOghO4jNIqAq0XLpD pjNK+AlsfHRAlaIkQoSUx6+ZwaxOQW8JbbfOQxWIwRU87ftJBuErSFxdsEiVoheQYmTM5+wgN jMAhISB1+8YJ7AyDsLSWoWktQCRqZVjBrFqUVlqUW6hgZ6SUWZ6RkluYmZOUCemV5uanFxYnp qTmJSsV5yfu4mRmDgMADBDsbj7+MOMUpyMCmJ8tbGHowU4kvKT6nMSCzOiC8qzUktPsQow8Gh JMHbCJITLEpNT61Iy8wBhjBMWoKDR0mEtwAkzVtckJhbnJkOkTrFqMvRcfPuHyYhlrz8vFQpc d4AkCIBkKKM0jy4EbB4usQoKyXMywh0lBBPQWpRbmYJqvwrRnEORiVh3o0gU3gy80rgNr0COo IJ6IjsDQdAjihJREhJNTBasIt92Vj35NFNZSGfn0vbb9ypsX6ysUVow9cZiSv3ON/KCbi3xkl Qwv3fhGnrU0ojJzQ+FBPIcylnz62fGrlMhoc1xcjSozFFOT23JfDg0+XbXkbKSVrw3dojUt0d UDjjDftKRh8OZrOc8wa30xM9eBM0k+fsvMJsxPRk9wEtRh4HFsszy5RYijMSDbWYi4oTAUsMV giiAgAA X-Env-Sender: prvs=42868d135=jennifer.herbert@citrix.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1505844830!64696209!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6020 invoked from network); 19 Sep 2017 18:13:52 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Sep 2017 18:13:52 -0000 X-IronPort-AV: E=Sophos;i="5.42,418,1500940800"; d="scan'208";a="440356271" From: Jennifer Herbert To: Ian Jackson , Wei Liu , , Date: Tue, 19 Sep 2017 19:06:27 +0100 Message-ID: <1505844387-2224-4-git-send-email-Jennifer.Herbert@citrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505844387-2224-1-git-send-email-Jennifer.Herbert@citrix.com> References: <1505844387-2224-1-git-send-email-Jennifer.Herbert@citrix.com> MIME-Version: 1.0 Cc: Jennifer Herbert Subject: [Xen-devel] [PATCH v2 3/3] RFC: migration: defer precopy policy to libxl X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Provide an implementation of the old policy as a callback in libxl and plumb it through the IPC machinery to libxc. This serves as an example for defining a libxl policy, and provides no advantage over the default policy in libxc. Signed-off-by: Joshua Otto Reviewed-by: Roger Pau Monné --- I have included this patch, as rfc, as requested by Ian, to show how libxl can provide a migration precopy policy. This was part of the same larger patch from Joshua - I have not changed or tested it. tools/libxl/libxl_dom_save.c | 20 ++++++++++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c index 77fe30e..6d28cce 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -328,6 +328,25 @@ int libxl__save_emulator_xenstore_data(libxl__domain_save_state *dss, return rc; } +/* + * This is the live migration precopy policy - it's called periodically during + * the precopy phase of live migrations, and is responsible for deciding when + * the precopy phase should terminate and what should be done next. + * + * The policy implemented here behaves identically to the policy previously + * hard-coded into xc_domain_save() - it proceeds to the stop-and-copy phase of + * the live migration when there are either fewer than 50 dirty pages, or more + * than 5 precopy rounds have completed. + */ +static int libxl__save_live_migration_simple_precopy_policy( + struct precopy_stats stats, void *user) +{ + return ((stats.dirty_count >= 0 && stats.dirty_count < 50) || + stats.iteration >= 5) + ? XGS_POLICY_STOP_AND_COPY + : XGS_POLICY_CONTINUE_PRECOPY; +} + /*----- main code for saving, in order of execution -----*/ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) @@ -401,6 +420,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_NONE) callbacks->suspend = libxl__domain_suspend_callback; + callbacks->precopy_policy = libxl__save_live_migration_simple_precopy_policy; callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty; dss->sws.ao = dss->ao; diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index 3ae7373..bb1d4e9 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -33,6 +33,7 @@ our @msgs = ( 'xen_pfn_t', 'console_gfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ], + [ 10, 'scxW', "precopy_policy", ['struct precopy_stats', 'stats'] ] ); #---------------------------------------- @@ -141,7 +142,8 @@ static void bytes_put(unsigned char *const buf, int *len, END -foreach my $simpletype (qw(int uint16_t uint32_t unsigned), 'unsigned long', 'xen_pfn_t') { +foreach my $simpletype (qw(int uint16_t uint32_t unsigned), + 'unsigned long', 'xen_pfn_t', 'struct precopy_stats') { my $typeid = typeid($simpletype); $out_body{'callout'} .= <