Re: [PATCH v10 1/3] KVM: Implement dirty quota-based throttling of vcpus

Sean Christopherson
2024-04-16T16:52:20Z

On Wed, Feb 21, 2024, Anish Moorthy wrote:
> > @@ -3656,6 +3669,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
> > struct kvm_memory_slot *memslot;
> >
> > memslot = gfn_to_memslot(kvm, gfn);
> > + update_dirty_quota(kvm, PAGE_SIZE);
> > mark_page_dirty_in_slot(kvm, memslot, gfn);
> > }
>
> Is mark_page_dirty() allowed to be used outside of a vCPU context?

It's allowed, but only because we don't have a better option, i.e. it's more
tolerated than allowed. :-)

> The lack of a vcpu* makes me think it is- I assume we don't want to charge
> vCPUs for accesses they're not making.
>
> Unfortunately we do seem to use it *in* vCPU contexts (see
> kvm_update_stolen_time() on arm64?), although not on x86 AFAICT.

Use what? mark_page_dirty_in_slot()? x86 _only_ uses it from vCPU context.