Re: [PATCH 11/11] KVM/MMU: Flush tlb in the kvm_age_rmapp()

From: Paolo Bonzini
Date: Mon Jan 07 2019 - 11:31:37 EST


On 07/01/19 04:42, Tianyu Lan wrote:
>> I'm assuming you're
>> clearing young to avoid the flush in kvm_mmu_notifier_clear_flush_young(),
>> but keeping that flush is silly since it will never be invoked. Just
>> squash this patch with patch 10/11 so that you can remove the unnecessary
>> flush in kvm_mmu_notifier_clear_flush_young() and preserve young.
>>
> The platform may provide tlb flush with address range as granularity. My changes
> are to use range flush when it's available. kvm_mmu_notifier_clear_flush_young()
> is common function for all platforms and most platforms still need the
> flush in the
> kvm_mmu_notifier_clear_flush_young(). I think it's better to separate
> flush request and
> "young" from return value of kvm_age_hva(). New flush parameter I
> added in the patch 10
> can be changed to a pointer and kvm_age_hva() can use it to return
> flush request.

There are two possibilities:

- pass a "bool *flush". If NULL, kvm_age_hva should not flush. If not
NULL, kvm_age_hva should receive a true *flush, and should change it to
false if kvm_age_hva takes care of the flush

- pass a "bool flush". In patch 10, change all kvm_age_hva
implementation to do the flush if they return 1.

I think I prefer the latter, in this case the small code duplication is
offset by a simpler API.

Paolo