Skip to contentSkip to conversation

migration: Report migration related thread pid to libvirt to support migration pin

PATCH RESEND In review Jiang Jiacheng via 3 participants 6 messages Jan 9, 2023 – Jan 12, 2023

lore
Share & tools
lore
#0 lore raw

cover migration: Report migration related thread pid to libvirt to support migration pin

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 RESEND 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 RESEND 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: [RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt

Quoted 4 lines · * Jiang Jiacheng via ([email protected]) wrote:

From: Zheng Chuan <[email protected]>

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

With multifd you may well want to pin different multifd threads to different cores; so you need to include the 'id' and 'name' fields of the multifd thread in the event.

(Copying in Jiri and Dan )

Dave

Quoted 54 lines
---
 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
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#4 lore raw

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

Quoted 9 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Jiang Jiacheng via ([email protected]) wrote:

From: Zheng Chuan <[email protected]>

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

With multifd you may well want to pin different multifd threads to different cores; so you need to include the 'id' and 'name' fields of the multifd thread in the event.

Are the 'id' / 'name' fields considered stable API for QEMU ?

IIRC, the mgmt app merely requests the number of multifd threads and doesn't assign any identifying names/ids to them, unlike iothreads where the mgmt app gives an explicit 'id'.

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 :|
#5 lore raw

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

Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Jiang Jiacheng via ([email protected]) wrote:

From: Zheng Chuan <[email protected]>

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

With multifd you may well want to pin different multifd threads to different cores; so you need to include the 'id' and 'name' fields of the multifd thread in the event.

Quoted 7 lines

Are the 'id' / 'name' fields considered stable API for QEMU ?

IIRC, the mgmt app merely requests the number of multifd threads and doesn't assign any identifying names/ids to them, unlike iothreads where the mgmt app gives an explicit 'id'.

If the 'id'/'name' of the migration thread is fixed in QEMU API, I think the related information can be added to the mgmt app to implement migration thread pin more properly.
And we are considering another choice, which provides a list of migration thread information for the mgmt app to actively query, so as to provide more information and avoid exposing thread PIDs to the mgmt app's public API.

Thanks
Jiang Jiacheng