From: Peter Xu Date: Fri, 13 Jun 2025 14:08:01 +0000 (-0400) Subject: migration/postcopy: Avoid clearing dirty bitmap for postcopy too X-Git-Tag: v10.1.0-rc0~25^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=adb13d6e42d6e0084e19a41303138d5d022e5904;p=thirdparty%2Fqemu.git migration/postcopy: Avoid clearing dirty bitmap for postcopy too This is a follow up on the other commit "migration/ram: avoid to do log clear in the last round" but for postcopy. https://lore.kernel.org/r/20250514115827.3216082-1-yanfei.xu@bytedance.com I can observe more than 10% reduction of average page fault latency during postcopy phase with this optimization: Before: 268.00us (+-1.87%) After: 232.67us (+-2.01%) The test was done with a 16GB VM with 80 vCPUs, running a workload that busy random writes to 13GB memory. Cc: Yanfei Xu Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20250613140801.474264-12-peterx@redhat.com Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- diff --git a/migration/ram.c b/migration/ram.c index e4871b4c17..7208bc114f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -835,8 +835,10 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs, * protections isn't needed as we know there will be either (1) no * further writes if migration will complete, or (2) migration fails * at last then tracking isn't needed either. + * + * Do the same for postcopy due to the same reason. */ - if (!rs->last_stage) { + if (!rs->last_stage && !migration_in_postcopy()) { /* * Clear dirty bitmap if needed. This _must_ be called before we * send any of the page in the chunk because we need to make sure