* [PULL 1/3] migration: Fix invalid %ud format and trace arg typo
2026-07-20 14:58 [PULL 0/3] Next patches Peter Xu
@ 2026-07-20 14:58 ` Peter Xu
2026-07-20 14:58 ` [PULL 2/3] migration: fix ineffective overflow assert in postcopy blocktime Peter Xu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2026-07-20 14:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Fabiano Rosas, Stefan Hajnoczi, Peter Xu, yujun
From: yujun <yujun@kylinos.cn>
Standard printf has no %ud conversion; glibc treats it as %u followed
by a literal 'd', so postcopy userfaultfd error messages printed event
values like "5d" instead of "5". The same typo existed in two postcopy
discard trace format strings.
Also rename the misspelled ram_save_iterate_big_wait() trace argument
milliconds to milliseconds.
Fixes: 00fa4fc85b ("postcopy: Allow registering of fd handler")
Signed-off-by: yujun <yujun@kylinos.cn>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20260630031324.43453-1-yujun@kylinos.cn
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/postcopy-ram.c | 4 ++--
migration/trace-events | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index f5ef93f193..980b938a4c 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1368,7 +1368,7 @@ static void *postcopy_ram_fault_thread(void *opaque)
}
}
if (msg.event != UFFD_EVENT_PAGEFAULT) {
- error_report("%s: Read unexpected event %ud from userfaultfd",
+ error_report("%s: Read unexpected event %u from userfaultfd",
__func__, msg.event);
continue; /* It's not a page fault, shouldn't happen */
}
@@ -1443,7 +1443,7 @@ retry:
}
}
if (msg.event != UFFD_EVENT_PAGEFAULT) {
- error_report("%s: Read unexpected event %ud "
+ error_report("%s: Read unexpected event %u "
"from userfaultfd (shared)",
__func__, msg.event);
continue; /* It's not a page fault, shouldn't happen */
diff --git a/migration/trace-events b/migration/trace-events
index de99d976ab..3b1258c3bf 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -21,14 +21,14 @@ loadvm_postcopy_handle_run(void) ""
loadvm_postcopy_handle_resume(void) ""
loadvm_postcopy_ram_handle_discard(void) ""
loadvm_postcopy_ram_handle_discard_end(void) ""
-loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud"
+loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %u"
loadvm_process_command(const char *s, uint16_t len) "com=%s len=%d"
loadvm_process_command_ping(uint32_t val) "0x%x"
loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switchover ack pending num=%u"
postcopy_ram_listen_thread_exit(void) ""
postcopy_ram_listen_thread_start(void) ""
qemu_savevm_send_postcopy_advise(void) ""
-qemu_savevm_send_postcopy_ram_discard(const char *id, uint16_t len) "%s: %ud"
+qemu_savevm_send_postcopy_ram_discard(const char *id, uint16_t len) "%s: %u"
savevm_command_send(uint16_t command, uint16_t len) "com=0x%x len=%d"
savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u"
savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, section_id %u -> %d"
@@ -119,7 +119,7 @@ colo_flush_ram_cache_begin(uint64_t dirty_pages) "dirty_pages %" PRIu64
colo_flush_ram_cache_end(void) ""
save_xbzrle_page_skipping(void) ""
save_xbzrle_page_overflow(void) ""
-ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations"
+ram_save_iterate_big_wait(uint64_t milliseconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations"
ram_load_start(void) ""
ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration %" PRIu64
ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PULL 2/3] migration: fix ineffective overflow assert in postcopy blocktime
2026-07-20 14:58 [PULL 0/3] Next patches Peter Xu
2026-07-20 14:58 ` [PULL 1/3] migration: Fix invalid %ud format and trace arg typo Peter Xu
@ 2026-07-20 14:58 ` Peter Xu
2026-07-20 14:58 ` [PULL 3/3] migration: clean up postcopy blocktime presentation Peter Xu
2026-07-20 17:11 ` [PULL 0/3] Next patches Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2026-07-20 14:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Fabiano Rosas, Stefan Hajnoczi, Peter Xu, Bin Guo
From: Bin Guo <guobin@linux.alibaba.com>
vcpu_faults_current[] is uint8_t. The overflow assert was checked
after the post-increment, so 255 would wrap to 0 and the assert
would pass silently. Move the check before the increment and use
< 255.
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Link: https://lore.kernel.org/r/20260716101952.65329-2-guobin@linux.alibaba.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/postcopy-ram.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 980b938a4c..b0828edb3e 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1093,7 +1093,11 @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,
/*
* Account how many concurrent faults on this vCPU we trapped. See
* comments above vcpu_faults_current[] on why it can be more than one.
+ *
+ * vcpu_faults_current[] is uint8_t, so assert before incrementing to
+ * catch overflow before it wraps.
*/
+ assert(dc->vcpu_faults_current[cpu] < 255);
if (dc->vcpu_faults_current[cpu]++ == 0) {
dc->smp_cpus_down++;
/*
@@ -1103,9 +1107,6 @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,
*/
dc->last_begin = current;
}
-
- /* Making sure it won't overflow - it really should never! */
- assert(dc->vcpu_faults_current[cpu] <= 255);
} else {
/*
* For non-vCPU thread faults, we don't care about tid or cpu index
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PULL 3/3] migration: clean up postcopy blocktime presentation
2026-07-20 14:58 [PULL 0/3] Next patches Peter Xu
2026-07-20 14:58 ` [PULL 1/3] migration: Fix invalid %ud format and trace arg typo Peter Xu
2026-07-20 14:58 ` [PULL 2/3] migration: fix ineffective overflow assert in postcopy blocktime Peter Xu
@ 2026-07-20 14:58 ` Peter Xu
2026-07-20 17:11 ` [PULL 0/3] Next patches Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2026-07-20 14:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Fabiano Rosas, Stefan Hajnoczi, Peter Xu, Bin Guo
From: Bin Guo <guobin@linux.alibaba.com>
Small cleanups for the postcopy blocktime fine-grained tracking
feature:
* Remove a redundant memset() on latency_buckets after g_new0().
* Use singular "Latency" in the HMP label for postcopy non-vCPU
latency, consistent with other single-value labels.
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Link: https://lore.kernel.org/r/20260716101952.65329-4-guobin@linux.alibaba.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration-hmp-cmds.c | 2 +-
migration/postcopy-ram.c | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 8b385f560e..7ec010fd05 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -95,7 +95,7 @@ static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info)
}
if (info->has_postcopy_non_vcpu_latency) {
- monitor_printf(mon, "Postcopy non-vCPU Latencies (ns): %" PRIu64 "\n",
+ monitor_printf(mon, "Postcopy non-vCPU Latency (ns): %" PRIu64 "\n",
info->postcopy_non_vcpu_latency);
}
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index b0828edb3e..a3314d3180 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -297,9 +297,6 @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void)
unsigned int smp_cpus = ms->smp.cpus;
PostcopyBlocktimeContext *ctx = g_new0(PostcopyBlocktimeContext, 1);
- /* Initialize all counters to be zeros */
- memset(ctx->latency_buckets, 0, sizeof(ctx->latency_buckets));
-
ctx->vcpu_blocktime_total = g_new0(uint64_t, smp_cpus);
ctx->vcpu_faults_count = g_new0(uint64_t, smp_cpus);
ctx->vcpu_faults_current = g_new0(uint8_t, smp_cpus);
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PULL 0/3] Next patches
2026-07-20 14:58 [PULL 0/3] Next patches Peter Xu
` (2 preceding siblings ...)
2026-07-20 14:58 ` [PULL 3/3] migration: clean up postcopy blocktime presentation Peter Xu
@ 2026-07-20 17:11 ` Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2026-07-20 17:11 UTC (permalink / raw)
To: Peter Xu; +Cc: qemu-devel, Fabiano Rosas, Stefan Hajnoczi, Peter Xu
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread