On 7/31/24 11:09, Hao Peng wrote:
Yep. And kvm_zap_obsolete_pages() is a relatively cheap nop if there are no
pages on active_mmu_pages. E.g. we could check kvm_memslots_have_rmaps(), but I
don't see any point in doing so, as the existing code should be blazing fast
relative to the total cost of the zap.
Here can be optimized by judging whether active_mmu_pages is empty,
just like kvm_zap_obsolete_pages.
Regardless of L0 kvm or L1 kvm, when tdp_mmu is enabled, the
active_mmu_pages list will not be used.
When ept=0 , the probability that active_mmu_pages is empty is also
high, not every time
kvm_zap_obsolete_pages is called.
So if anything you could check list_empty(&kvm->arch.active_mmu_pages)
before the loop of kvm_zap_obsolete_pages(), similar to what is done in
kvm_mmu_zap_oldest_mmu_pages(). I doubt it can have any practical
benefit, though.
Paolo