On Mon, Oct 17, 2022, Shivam Kumar wrote: > > On 10/10/22 11:11 am, Shivam Kumar wrote: > > > > On 15/09/22 3:40 pm, Shivam Kumar wrote: > > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > > > index 3ca3db020e0e..263a588f3cd3 100644 > > > --- a/include/linux/kvm_types.h > > > +++ b/include/linux/kvm_types.h > > > @@ -118,6 +118,7 @@ struct kvm_vcpu_stat_generic { > > > u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT]; > > > u64 halt_wait_hist[HALT_POLL_HIST_COUNT]; > > > u64 blocking; > > > + u64 pages_dirtied; > > I am reworking the QEMU patches and I am not sure how I can access the > > pages_dirtied info from the userspace side when the migration starts, i.e. > > without a dirty quota exit. > > > > I need this info to initialise the dirty quota. This is what I am looking > > to do on the userspace side at the start of dirty quota migration: > > dirty_quota = pages_dirtied + some initial quota > > > > Hoping if you could help, Sean. Thanks in advance. > I think I can set dirty_quota initially to 1 and let the vpcu exit with exit > reason KVM_EXIT_DIRTY_QUOTA_EXHAUSTED. Then, I can set the quota. The vCPU doesn't need to be paused to read stats, pages_dirtied can be read while the vCPU is running via KVM_GET_STATS_FD. Though at a glance, QEMU doesn't yet utilize KVM_GETS_STATS_FD, i.e. QEMU would a need a decent chunk of infrastructure improvements to avoid the unnecessary exit.