Skip to content

Commit 30e834d

Browse files
LilyaBuigsilya
andcommitted
netdev-dpdk: Post-copy Live Migration support for vhost-user-client.
Post-copy Live Migration for vHost supported since DPDK 18.11 and QEMU 2.12. New global config option 'vhost-postcopy-support' added to control this feature. Ex.: ovs-vsctl set Open_vSwitch . other_config:vhost-postcopy-support=true Changing this value requires restarting the daemon. It's safe to enable this knob even if QEMU doesn't support post-copy LM. Feature marked as experimental and disabled by default because it may cause PMD thread hang on destination host on page fault for the time of page downloading from the source. Feature is not compatible with 'mlockall' and 'dequeue zero-copy'. Support added only for vhost-user-client. Signed-off-by: Liliia Butorina <l.butorina@partner.samsung.com> Co-authored-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
1 parent da05d1c commit 30e834d

File tree

7 files changed

+99
-1
lines changed

7 files changed

+99
-1
lines changed

Documentation/topics/dpdk/vhost-user.rst

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ the guest. There are two ways to do this: using QEMU directly, or using
111111
libvirt.
112112

113113
.. note::
114-
IOMMU is not supported with vhost-user ports.
114+
115+
IOMMU and Post-copy Live Migration are not supported with vhost-user ports.
115116

116117
Adding vhost-user ports to the guest (QEMU)
117118
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -301,6 +302,52 @@ The default value is false.
301302
QEMU). Starting with QEMU v2.9.1, vhost-iommu-support can safely be
302303
enabled, even without having an IOMMU device, with no performance penalty.
303304

305+
vhost-user-client Post-copy Live Migration Support (experimental)
306+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307+
308+
``Post-copy`` migration is the migration mode where the destination CPUs are
309+
started before all the memory has been transferred. The main advantage is the
310+
predictable migration time. Mostly used as a second phase after the normal
311+
'pre-copy' migration in case it takes too long to converge.
312+
313+
More information can be found in QEMU `docs`_.
314+
315+
.. _`docs`: https://git.qemu.org/?p=qemu.git;a=blob;f=docs/devel/migration.rst
316+
317+
Post-copy support may be enabled via a global config value
318+
``vhost-postcopy-support``. Setting this to ``true`` enables Post-copy support
319+
for all vhost-user-client ports::
320+
321+
$ ovs-vsctl set Open_vSwitch . other_config:vhost-postcopy-support=true
322+
323+
The default value is ``false``.
324+
325+
.. important::
326+
327+
Changing this value requires restarting the daemon.
328+
329+
.. important::
330+
331+
DPDK Post-copy migration mode uses userfaultfd syscall to communicate with
332+
the kernel about page fault handling and uses shared memory based on huge
333+
pages. So destination host linux kernel should support userfaultfd over
334+
shared hugetlbfs. This feature only introduced in kernel upstream version
335+
4.11.
336+
337+
Post-copy feature supported in DPDK since 18.11.0 version and in QEMU
338+
since 2.12.0 version. But it's suggested to use QEMU >= 3.0.1 because
339+
migration recovery was fixed for post-copy in 3.0 and few additional bug
340+
fixes (like userfaulfd leak) was released in 3.0.1.
341+
342+
DPDK Post-copy feature requires avoiding to populate the guest memory
343+
(application must not call mlock* syscall). So enabling mlockall and
344+
dequeue zero-copy features is mis-compatible with post-copy feature.
345+
346+
Note that during migration of vhost-user device, PMD threads hang for the
347+
time of faulted pages download from source host. Transferring 1GB hugepage
348+
across a 10Gbps link possibly unacceptably slow. So recommended hugepage
349+
size is 2MB.
350+
304351
.. _dpdk-testpmd:
305352

306353
DPDK in the Guest
@@ -500,6 +547,10 @@ QEMU versions v2.10 and greater). This value can be set like so::
500547

501548
Because of this limitation, this feature is considered 'experimental'.
502549

550+
.. note::
551+
552+
Post-copy Live Migration is not compatible with dequeue zero copy.
553+
503554
Further information can be found in the
504555
`DPDK documentation
505556
<https://doc.dpdk.org/guides-18.11/prog_guide/vhost_lib.html>`__

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Post-v2.11.0
33
- DPDK:
44
* New option 'other_config:dpdk-socket-limit' to limit amount of
55
hugepage memory that can be used by DPDK.
6+
* Add support for vHost Post-copy Live Migration (experimental).
67
* OVS validated with DPDK 18.11.1 which is recommended to be used.
78
- OpenFlow:
89
* Removed support for OpenFlow 1.6 (draft), which ONF abandoned.

lib/dpdk-stub.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ dpdk_vhost_iommu_enabled(void)
5656
return false;
5757
}
5858

59+
bool
60+
dpdk_vhost_postcopy_enabled(void)
61+
{
62+
return false;
63+
}
64+
5965
bool
6066
dpdk_per_port_memory(void)
6167
{

lib/dpdk.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "ovs-numa.h"
4040
#include "smap.h"
4141
#include "svec.h"
42+
#include "util.h"
4243
#include "vswitch-idl.h"
4344

4445
VLOG_DEFINE_THIS_MODULE(dpdk);
@@ -47,6 +48,8 @@ static FILE *log_stream = NULL; /* Stream for DPDK log redirection */
4748

4849
static char *vhost_sock_dir = NULL; /* Location of vhost-user sockets */
4950
static bool vhost_iommu_enabled = false; /* Status of vHost IOMMU support */
51+
static bool vhost_postcopy_enabled = false; /* Status of vHost POSTCOPY
52+
* support. */
5053
static bool dpdk_initialized = false; /* Indicates successful initialization
5154
* of DPDK. */
5255
static bool per_port_memory = false; /* Status of per port memory support */
@@ -311,6 +314,15 @@ dpdk_init__(const struct smap *ovs_other_config)
311314
VLOG_INFO("IOMMU support for vhost-user-client %s.",
312315
vhost_iommu_enabled ? "enabled" : "disabled");
313316

317+
vhost_postcopy_enabled = smap_get_bool(ovs_other_config,
318+
"vhost-postcopy-support", false);
319+
if (vhost_postcopy_enabled && memory_locked()) {
320+
VLOG_WARN("vhost-postcopy-support and mlockall are not compatible.");
321+
vhost_postcopy_enabled = false;
322+
}
323+
VLOG_INFO("POSTCOPY support for vhost-user-client %s.",
324+
vhost_postcopy_enabled ? "enabled" : "disabled");
325+
314326
per_port_memory = smap_get_bool(ovs_other_config,
315327
"per-port-memory", false);
316328
VLOG_INFO("Per port memory for DPDK devices %s.",
@@ -492,6 +504,12 @@ dpdk_vhost_iommu_enabled(void)
492504
return vhost_iommu_enabled;
493505
}
494506

507+
bool
508+
dpdk_vhost_postcopy_enabled(void)
509+
{
510+
return vhost_postcopy_enabled;
511+
}
512+
495513
bool
496514
dpdk_per_port_memory(void)
497515
{

lib/dpdk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void dpdk_init(const struct smap *ovs_other_config);
3939
void dpdk_set_lcore_id(unsigned cpu);
4040
const char *dpdk_get_vhost_sock_dir(void);
4141
bool dpdk_vhost_iommu_enabled(void);
42+
bool dpdk_vhost_postcopy_enabled(void);
4243
bool dpdk_per_port_memory(void);
4344
void print_dpdk_version(void);
4445
void dpdk_status(const struct ovsrec_open_vswitch *);

lib/netdev-dpdk.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,6 +4147,11 @@ netdev_dpdk_vhost_client_reconfigure(struct netdev *netdev)
41474147
vhost_flags |= RTE_VHOST_USER_IOMMU_SUPPORT;
41484148
}
41494149

4150+
/* Enable POSTCOPY support, if explicitly requested. */
4151+
if (dpdk_vhost_postcopy_enabled()) {
4152+
vhost_flags |= RTE_VHOST_USER_POSTCOPY_SUPPORT;
4153+
}
4154+
41504155
zc_enabled = dev->vhost_driver_flags
41514156
& RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
41524157
/* Enable zero copy flag, if requested */

vswitchd/vswitch.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,22 @@
406406
</p>
407407
</column>
408408

409+
<column name="other_config" key="vhost-postcopy-support"
410+
type='{"type": "boolean"}'>
411+
<p>
412+
vHost post-copy is a feature which allows switching live migration
413+
of VM attached to dpdkvhostuserclient port to post-copy mode if
414+
default pre-copy migration can not be converged or takes too long to
415+
converge.
416+
Setting this value to <code>true</code> enables vHost post-copy
417+
support for all dpdkvhostuserclient ports. Available starting from
418+
DPDK v18.11 and QEMU 2.12.
419+
</p>
420+
<p>
421+
Changing this value requires restarting the daemon.
422+
</p>
423+
</column>
424+
409425
<column name="other_config" key="per-port-memory"
410426
type='{"type": "boolean"}'>
411427
<p>

0 commit comments

Comments
 (0)