Skip to contentSkip to conversation

migration: Report migration related thread pid to libvirt to

PATCH Superseded Jiang Jiacheng via 2 participants 4 messages Jan 9, 2023

lore
Share & tools
lore
#0 lore raw

cover migration: Report migration related thread pid to libvirt to

By default, the migration thread shares CPU resources with the VM process. With migration pin, support pin migration thread to expected CPU list to avoid preempting CPU resources of VM process.
To support migration pin, we need report migration related thread pid to libvirt.

libvirt patches:
https://listman.redhat.com/archives/libvir-list/2023-January/236561.html

Zheng Chuan (2):
migration: report migration related thread pid to libvirt
migration: report multiFd related thread pid to libvirt

 migration/migration.c |  3 +++
 migration/multifd.c   |  4 ++++
 qapi/migration.json   | 24 ++++++++++++++++++++++++
 3 files changed, 31 insertions(+)
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/2 migration: report migration related thread pid to libvirt

From: Zheng Chuan <[email protected]>

Report migration thread pid to libvirt in order to pin migration thread to different cpu.

---
 migration/migration.c |  3 +++
 qapi/migration.json   | 12 ++++++++++++
 2 files changed, 15 insertions(+)
migration/migration.c +3 -0
index 52b5d39244..2534e5a1f1 100644
@@ -3955,6 +3955,9 @@ static void *migration_thread(void *opaque)
     MigThrError thr_error;
     bool urgent = false;
 
+    /* report migration thread pid to libvirt */
+    qapi_event_send_migration_pid(qemu_get_thread_id());
+
     rcu_register_thread();
 
     object_ref(OBJECT(s));
qapi/migration.json +12 -0
index 88ecf86ac8..aafc940617 100644
@@ -1286,6 +1286,18 @@
 { 'event': 'MIGRATION_PASS',
   'data': { 'pass': 'int' } }
 
+##
+# @MIGRATION_PID:
+#
+# Emitted when migration thread appear
+#
+# @pid: pid of migration thread
+#
+# Since: 7.2
+##
+{ 'event': 'MIGRATION_PID',
+  'data': { 'pid': 'int' } }
+
 ##
 # @COLOMessage:
 #
Signature · 1 line
2.33.0
#2 lore raw

PATCH 2/2 migration: report multiFd related thread pid to libvirt

In reply to Jiang Jiacheng via

From: Zheng Chuan <[email protected]>

Report multiFd related thread pid to libvirt in order to pin multiFd thread to different cpu.

---
 migration/multifd.c |  4 ++++
 qapi/migration.json | 12 ++++++++++++
 2 files changed, 16 insertions(+)
migration/multifd.c +4 -0
index 000ca4d4ec..f3f7e8ae31 100644
@@ -17,6 +17,7 @@
 #include "exec/ramblock.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "qapi/qapi-events-migration.h"
 #include "ram.h"
 #include "migration.h"
 #include "socket.h"
@@ -650,6 +651,9 @@ static void *multifd_send_thread(void *opaque)
     int ret = 0;
     bool use_zero_copy_send = migrate_use_zero_copy_send();
 
+    /* report multifd thread pid to libvirt */
+    qapi_event_send_migration_multifd_pid(qemu_get_thread_id());
+
     trace_multifd_send_thread_start(p->id);
     rcu_register_thread();
 
qapi/migration.json +12 -0
index aafc940617..33fc319329 100644
@@ -1286,6 +1286,18 @@
 { 'event': 'MIGRATION_PASS',
   'data': { 'pass': 'int' } }
 
+##
+# @MIGRATION_MULTIFD_PID:
+#
+# Emitted when multifd thread appear
+#
+# @pid: pid of multifd thread
+#
+# Since: 7.2
+##
+{ 'event': 'MIGRATION_MULTIFD_PID',
+  'data': { 'pid': 'int' } }
+
 ##
 # @MIGRATION_PID:
 #
Signature · 1 line
2.33.0
#3 lore raw

Re: [PATCH 2/2] migration: report multiFd related thread pid to libvirt

Quoted 40 lines · Jiang Jiacheng via

From: Zheng Chuan <[email protected]>

Report multiFd related thread pid to libvirt in order to pin multiFd thread to different cpu.

---
 migration/multifd.c |  4 ++++
 qapi/migration.json | 12 ++++++++++++
 2 files changed, 16 insertions(+)
migration/multifd.c +4 -0
index 000ca4d4ec..f3f7e8ae31 100644
@@ -17,6 +17,7 @@
 #include "exec/ramblock.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "qapi/qapi-events-migration.h"
 #include "ram.h"
 #include "migration.h"
 #include "socket.h"
@@ -650,6 +651,9 @@ static void *multifd_send_thread(void *opaque)
     int ret = 0;
     bool use_zero_copy_send = migrate_use_zero_copy_send();
 
+    /* report multifd thread pid to libvirt */
+    qapi_event_send_migration_multifd_pid(qemu_get_thread_id());
+
     trace_multifd_send_thread_start(p->id);
     rcu_register_thread();
 
qapi/migration.json +1 -0
index aafc940617..33fc319329 100644
@@ -1286,6 +1286,18 @@
 { 'event': 'MIGRATION_PASS',
   'data': { 'pass': 'int' } }
 
+##

qapi/migration.json line 1299

Quoted 10 lines
qapi/migration.json +10 -0
+# @MIGRATION_MULTIFD_PID:
+#
+# Emitted when multifd thread appear
+#
+# @pid: pid of multifd thread
+#
+# Since: 7.2
+##
+{ 'event': 'MIGRATION_MULTIFD_PID',
+  'data': { 'pid': 'int' } }

Why do we need to have separate events instead of emitting MIGRATION_PID multiple times, possibly with a 'type' field if clients genuinely need to distinguish multifd threads.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|