On 11/08/21 00:56, Oliver Upton wrote:
What if the statistic was 'dirtied_pages', which records the number of
pages dirtied in the lifetime of a VM? Userspace could just record the
value each time it blows away the dirty bitmaps and subtract that
value next time it reads the stat. It would circumvent the need to
walk the entire dirty bitmap to keep the statistic sane.
Yeah, that'd be much better also because the "number of dirty pages"
statistic is not well defined in init-all-dirty mode.
Making it a vCPU stat works in fact, because mark_page_dirty_in_slot is
only called with kvm_get_running_vcpu() != NULL; see
kvm_dirty_ring_get() in virt/kvm/dirty_ring.c.
+ if (kvm->dirty_ring_size) {
kvm_dirty_ring_push(kvm_dirty_ring_get(kvm),
slot, rel_gfn);
- else
+ } else {
set_bit_le(rel_gfn, memslot->dirty_bitmap);
+ ++kvm->stat.generic.dirty_pages;
+ }
Aren't pages being pushed out to the dirty ring just as dirty?
Yes, they are.
Paolo