On Sun, Jun 27, 2021 at 01:38:17PM +0800, huang...@chinatelecom.cn wrote: > +static void calculate_dirtyrate_dirty_bitmap(struct DirtyRateConfig config) > +{ > + int64_t msec = 0; > + int64_t start_time; > + uint64_t protect_flags = 0; > + uint64_t initially_set = 0; > + uint64_t protect_only = 0; > + > + protect_flags = kvm_get_manual_dirty_log_protect(); > + protect_only = KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE; > + initially_set = > + (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | KVM_DIRTY_LOG_INITIALLY_SET); > + > + dirtyrate_global_dirty_log_start(); > + > + /* absense of migration */ > + if (!(global_dirty_tracking & GLOBAL_DIRTY_MIGRATION)) { > + if ((protect_flags & initially_set) == initially_set) { > + /* skip the 1'round which return all 1 bits */ > + memory_global_dirty_log_sync(); > + /* > + * reset page protect manually and > + * start dirty tracking from now on > + **/ > + dirtyrate_manual_reset_protect(); > + } > + }
Right, clear dirty log is a bit tricky. Wondering whether we can simplify this into something like: 1. dirty_log_sync() 2. if (manual_protect) reset_protect() 3. record initial total dirty stats (total dirty stats updated when sync) 4. sleep(SECONDS) 5. dirty_log_sync() 6. record final total dirty stats Then I think it's not related to initial-all-set anymore. Do you think this would work? Thanks, -- Peter Xu