All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] migration/rdma: Use huge page register VM memory
@ 2021-06-07 13:57 LIZHAOXIN1 [李照鑫]
  2021-06-07 14:17 ` Daniel P. Berrangé
  0 siblings, 1 reply; 5+ messages in thread
From: LIZHAOXIN1 [李照鑫] @ 2021-06-07 13:57 UTC (permalink / raw)
  To: qemu-devel, quintela, dgilbert
  Cc: LIZHAOXIN1 [李照鑫], sunhao2 [孙昊],
	DENGLINWEN [邓林文],
	YANGFENG1 [杨峰]

When using libvirt for RDMA live migration, if the VM memory is too large,
it will take a lot of time to deregister the VM at the source side, resulting
in a long downtime (VM 64G, deregister vm time is about 400ms).
    
Although the VM's memory uses 2M huge pages, the MLNX driver still uses 4K
pages for pin memory, as well as for unpin. So we use huge pages to skip the
process of pin memory and unpin memory to reduce downtime.
   
The test environment:
kernel: linux-5.12
MLNX: ConnectX-4 LX
libvirt command:
virsh migrate --live --p2p --persistent --copy-storage-inc --listen-address \
0.0.0.0 --rdma-pin-all --migrateuri rdma://192.168.0.2 [VM] qemu+tcp://192.168.0.2/system
    
Signed-off-by: lizhaoxin <lizhaoxin1@kingsoft.com>

diff --git a/migration/rdma.c b/migration/rdma.c
index 1cdb4561f3..9823449297 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1123,13 +1123,26 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma)
     RDMALocalBlocks *local = &rdma->local_ram_blocks;
 
     for (i = 0; i < local->nb_blocks; i++) {
-        local->block[i].mr =
-            ibv_reg_mr(rdma->pd,
-                    local->block[i].local_host_addr,
-                    local->block[i].length,
-                    IBV_ACCESS_LOCAL_WRITE |
-                    IBV_ACCESS_REMOTE_WRITE
-                    );
+        if (strcmp(local->block[i].block_name,"pc.ram") == 0) {
+            local->block[i].mr =
+                ibv_reg_mr(rdma->pd,
+                        local->block[i].local_host_addr,
+                        local->block[i].length,
+                        IBV_ACCESS_LOCAL_WRITE |
+                        IBV_ACCESS_REMOTE_WRITE |
+                        IBV_ACCESS_ON_DEMAND |
+                        IBV_ACCESS_HUGETLB
+                        );
+        } else {
+            local->block[i].mr =
+                ibv_reg_mr(rdma->pd,
+                        local->block[i].local_host_addr,
+                        local->block[i].length,
+                        IBV_ACCESS_LOCAL_WRITE |
+                        IBV_ACCESS_REMOTE_WRITE
+                        );
+        }
+
         if (!local->block[i].mr) {
             perror("Failed to register local dest ram block!\n");
             break;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-10 15:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 13:57 [PATCH] migration/rdma: Use huge page register VM memory LIZHAOXIN1 [李照鑫]
2021-06-07 14:17 ` Daniel P. Berrangé
2021-06-07 15:00   ` Dr. David Alan Gilbert
2021-06-10 15:35     ` 回复: " LIZHAOXIN1 [李照鑫]
2021-06-10 15:33   ` LIZHAOXIN1 [李照鑫]

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.