Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-27 Thread Paolo Bonzini
On 26/01/21 23:02, Sean Christopherson wrote: You can do the deferred freeing with a short write-side critical section to ensure all readers have terminated. Hmm, the most obvious downside I see is that the zap_collapsible_sptes() case will not scale as well as the RCU approach. E.g. the lock

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Ben Gardon
On Tue, Jan 26, 2021 at 5:37 AM Paolo Bonzini wrote: > > On 12/01/21 19:10, Ben Gardon wrote: > > + * May be acquired under the MMU lock in read mode or non-overlapping > > + * with the MMU lock. > > + */ > > + spinlock_t tdp_mmu_pages_lock; > > Is this correct? My understand

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Sean Christopherson
On Tue, Jan 26, 2021, Sean Christopherson wrote: > On Tue, Jan 26, 2021, Paolo Bonzini wrote: > > On 21/01/21 22:32, Sean Christopherson wrote: > > > Coming back to this series, I wonder if the RCU approach is truly > > > necessary to > > > get the desired scalability. If both zap_collapsible_spt

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Sean Christopherson
On Tue, Jan 26, 2021, Paolo Bonzini wrote: > On 21/01/21 22:32, Sean Christopherson wrote: > > Coming back to this series, I wonder if the RCU approach is truly necessary > > to > > get the desired scalability. If both zap_collapsible_sptes() and NX huge > > page > > recovery zap_only_ leaf SPT

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Ben Gardon
On Tue, Jan 26, 2021 at 6:28 AM Paolo Bonzini wrote: > > On 21/01/21 22:32, Sean Christopherson wrote: > > Coming back to this series, I wonder if the RCU approach is truly necessary > > to > > get the desired scalability. If both zap_collapsible_sptes() and NX huge > > page > > recovery zap_on

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Paolo Bonzini
On 21/01/21 22:32, Sean Christopherson wrote: Coming back to this series, I wonder if the RCU approach is truly necessary to get the desired scalability. If both zap_collapsible_sptes() and NX huge page recovery zap_only_ leaf SPTEs, then the only path that can actually unlink a shadow page whi

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-26 Thread Paolo Bonzini
On 12/01/21 19:10, Ben Gardon wrote: +* May be acquired under the MMU lock in read mode or non-overlapping +* with the MMU lock. +*/ + spinlock_t tdp_mmu_pages_lock; Is this correct? My understanding is that: - you can take tdp_mmu_pages_lock from a shared MMU

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-21 Thread Sean Christopherson
On Thu, Jan 21, 2021, Sean Christopherson wrote: > On Tue, Jan 12, 2021, Ben Gardon wrote: > > +static void tdp_mmu_unlink_page(struct kvm *kvm, struct kvm_mmu_page *sp, > > + bool atomic) > > +{ > > + if (atomic) > > Summarizing an off-list discussion with Ben: > > Th

Re: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-21 Thread Sean Christopherson
On Tue, Jan 12, 2021, Ben Gardon wrote: > Add a lock to protect the data structures that track the page table > memory used by the TDP MMU. In order to handle multiple TDP MMU > operations in parallel, pages of PT memory must be added and removed > without the exclusive protection of the MMU lock.

[PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock

2021-01-12 Thread Ben Gardon
Add a lock to protect the data structures that track the page table memory used by the TDP MMU. In order to handle multiple TDP MMU operations in parallel, pages of PT memory must be added and removed without the exclusive protection of the MMU lock. A new lock to protect the list(s) of in-use page