From patchwork Mon Sep 25 18:55:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jennifer Herbert X-Patchwork-Id: 9970365 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 7960460365 for ; Mon, 25 Sep 2017 18:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 381F6288D0 for ; Mon, 25 Sep 2017 18:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB6F28CB8; Mon, 25 Sep 2017 18:58:44 +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 895FB288D0 for ; Mon, 25 Sep 2017 18:58:42 +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 1dwYYC-0000yp-NL; Mon, 25 Sep 2017 18:56:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwYYC-0000yO-2c for xen-devel@lists.xenproject.org; Mon, 25 Sep 2017 18:56:16 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 4A/3B-02092-F4159C95; Mon, 25 Sep 2017 18:56:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXitHRDpK5f4Ml Ig807rSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozGDZvYCj5KVDz71s7cwDhJpIuRk0NCwF9i 5ZE/LF2MHBxsAiYSbx6EdjFycYgItDBKLD61ix0kzixgJNF2lBukXFjAVeLW1p1MIGEWAVWJv pl6IGFeAR+Jj33L2SAmKkhMefieGcTmFPCV2PP3AFhcCKhmU9NbNoh6QYmTM5+wgNjMApoSrd t/s0PY8hLNW2czQ9RrSJxdsIh1AiPfLCQts5C0zELSsoCReRWjRnFqUVlqka6RhV5SUWZ6Rkl uYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRmCg1TMwMO5g7Fvld4hRkoNJSZT3Lt+JSCG+pPyU yozE4oz4otKc1OJDjDIcHEoSvKUBJyOFBItS01Mr0jJzgCEPk5bg4FES4RUDSfMWFyTmFmemQ 6ROMepydNy8+4dJiCUvPy9VSpy3D6RIAKQoozQPbgQs/i4xykoJ8zIyMDAI8RSkFuVmlqDKv2 IU52BUEuadDDKFJzOvBG7TK6AjmICO6J16AuSIkkSElFQDo7V/1qQW/Q0nXjO4PRU8K8uW9ue ArcSDsGUvPViurjr3IbRmt212Y1OFSqTWZg4Xzu2pVZUBt7YZf5Pd1Tt/0ueYqRZ/vK6019n/ 9l7+fF/3qc5Ixc7yBfLXuD7XTKj7EbQxpnEGs/odJgvJB39PHzzhNSsuTf7/yaTA+uQ77/I9e lxvbJeLVmIpzkg01GIuKk4EAHzrjT+6AgAA X-Env-Sender: prvs=434979fdc=jennifer.herbert@citrix.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1506365771!84756286!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 58786 invoked from network); 25 Sep 2017 18:56:14 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Sep 2017 18:56:14 -0000 X-IronPort-AV: E=Sophos;i="5.42,437,1500940800"; d="scan'208";a="441140452" From: Jennifer Herbert To: Ian Jackson , Wei Liu , , Date: Mon, 25 Sep 2017 19:55:35 +0100 Message-ID: <1506365735-133776-4-git-send-email-Jennifer.Herbert@citrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506365735-133776-1-git-send-email-Jennifer.Herbert@citrix.com> References: <1506365735-133776-1-git-send-email-Jennifer.Herbert@citrix.com> MIME-Version: 1.0 Cc: Jennifer Herbert Subject: [Xen-devel] [PATCH v3 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é --- 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'} .= <