[PATCH] Migration: Add trace points for vmstate handler insertion/removal

Peter Xu posted 1 patch 4 days, 6 hours ago
migration/savevm.c     | 7 +++++++
migration/trace-events | 2 ++
2 files changed, 9 insertions(+)
[PATCH] Migration: Add trace points for vmstate handler insertion/removal
Posted by Peter Xu 4 days, 6 hours ago
SaveStateEntry has lots of magics internally, on alias_id, get_id() being
able to overwrite the original idstr, compat fields, ID_ANY, and so on.  It
may not be always clear that what all these fields are being registered for
some device we care.

Add trace points for SaveStateEntry insertions/removals, so that we know
what was being registered.  For insertions, we dump everything that might
be useful.  For removal, only section_id is needed because that's the
unique identifier for an SeveStateEntry.

Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/savevm.c     | 7 +++++++
 migration/trace-events | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index e796436979..57f058bd40 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -718,6 +718,11 @@ static void savevm_state_handler_insert(SaveStateEntry *nse)
 
     assert(priority <= MIG_PRI_MAX);
 
+    trace_vmstate_handler_insert(
+        nse->idstr, nse->instance_id, nse->alias_id, nse->version_id,
+        nse->section_id, nse->compat ? nse->compat->idstr : NULL,
+        nse->compat ? nse->compat->instance_id : 0);
+
     /*
      * This should never happen otherwise migration will probably fail
      * silently somewhere because we can be wrongly applying one
@@ -754,6 +759,8 @@ static void savevm_state_handler_remove(SaveStateEntry *se)
     SaveStateEntry *next;
     MigrationPriority priority = save_state_priority(se);
 
+    trace_vmstate_handler_remove(se->section_id);
+
     if (se == savevm_state.handler_pri_head[priority]) {
         next = QTAILQ_NEXT(se, entry);
         if (next != NULL && save_state_priority(next) == priority) {
diff --git a/migration/trace-events b/migration/trace-events
index 0638183056..3411f2f699 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -50,6 +50,8 @@ vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s"
 vmstate_downtime_save(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64
 vmstate_downtime_load(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64
 vmstate_downtime_checkpoint(const char *checkpoint) "%s"
+vmstate_handler_insert(char *idstr, uint32_t instance_id, int alias_id, int version_id, int section_id, char *compat_idstr, int compat_instance_id) "id=%s instance_id=%"PRIu32" alias_id=%d version_id=%d section_id=%d compat_id=%s compat_instance_id=%d"
+vmstate_handler_remove(int section_id) "section_id=%d"
 postcopy_pause_incoming(void) ""
 postcopy_pause_incoming_continued(void) ""
 postcopy_page_req_sync(void *host_addr) "sync page req %p"
-- 
2.45.0
Re: [PATCH] Migration: Add trace points for vmstate handler insertion/removal
Posted by Peter Xu 3 days, 23 hours ago
On Fri, Oct 18, 2024 at 10:44:26AM -0400, Peter Xu wrote:
> SaveStateEntry has lots of magics internally, on alias_id, get_id() being
> able to overwrite the original idstr, compat fields, ID_ANY, and so on.  It
> may not be always clear that what all these fields are being registered for
> some device we care.
> 
> Add trace points for SaveStateEntry insertions/removals, so that we know
> what was being registered.  For insertions, we dump everything that might
> be useful.  For removal, only section_id is needed because that's the
> unique identifier for an SeveStateEntry.
> 
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Fabiano Rosas <farosas@suse.de>
> Signed-off-by: Peter Xu <peterx@redhat.com>

queued.

-- 
Peter Xu
Re: [PATCH] Migration: Add trace points for vmstate handler insertion/removal
Posted by Fabiano Rosas 4 days, 6 hours ago
Peter Xu <peterx@redhat.com> writes:

> SaveStateEntry has lots of magics internally, on alias_id, get_id() being
> able to overwrite the original idstr, compat fields, ID_ANY, and so on.  It
> may not be always clear that what all these fields are being registered for
> some device we care.
>
> Add trace points for SaveStateEntry insertions/removals, so that we know
> what was being registered.  For insertions, we dump everything that might
> be useful.  For removal, only section_id is needed because that's the
> unique identifier for an SeveStateEntry.
>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Fabiano Rosas <farosas@suse.de>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>