[PATCH v2 0/4] KVM: x86/mmu: small locking cleanups

Paolo Bonzini posted 4 patches 2 years ago
Documentation/virt/kvm/locking.rst |  7 +--
arch/x86/include/asm/kvm_host.h    | 11 ++--
arch/x86/kvm/mmu/mmu.c             |  6 +-
arch/x86/kvm/mmu/tdp_mmu.c         | 90 ++++++++++++++----------------
arch/x86/kvm/mmu/tdp_mmu.h         |  3 +-
5 files changed, 54 insertions(+), 63 deletions(-)
[PATCH v2 0/4] KVM: x86/mmu: small locking cleanups
Posted by Paolo Bonzini 2 years ago
Remove "bool shared" argument from functions and iterators that need
not know if the lock is taken for read or write.  This is common because
protection is achieved via RCU and tdp_mmu_pages_lock or because the
argument is only used for assertions that can be written by hand.

Also always take tdp_mmu_pages_lock even if mmu_lock is currently taken
for write.

Paolo Bonzini (4):
  KVM: x86/mmu: remove unnecessary "bool shared" argument from functions
  KVM: x86/mmu: remove unnecessary "bool shared" argument from iterators
  KVM: x86/mmu: always take tdp_mmu_pages_lock
  KVM: x86/mmu: fix comment about mmu_unsync_pages_lock

 Documentation/virt/kvm/locking.rst |  7 +--
 arch/x86/include/asm/kvm_host.h    | 11 ++--
 arch/x86/kvm/mmu/mmu.c             |  6 +-
 arch/x86/kvm/mmu/tdp_mmu.c         | 90 ++++++++++++++----------------
 arch/x86/kvm/mmu/tdp_mmu.h         |  3 +-
 5 files changed, 54 insertions(+), 63 deletions(-)

-- 
2.39.1
Re: [PATCH v2 0/4] KVM: x86/mmu: small locking cleanups
Posted by Sean Christopherson 2 years ago
On Sat, 25 Nov 2023 03:33:56 -0500, Paolo Bonzini wrote:
> Remove "bool shared" argument from functions and iterators that need
> not know if the lock is taken for read or write.  This is common because
> protection is achieved via RCU and tdp_mmu_pages_lock or because the
> argument is only used for assertions that can be written by hand.
> 
> Also always take tdp_mmu_pages_lock even if mmu_lock is currently taken
> for write.
> 
> [...]

Applied to kvm-x86 mmu, thanks!

[1/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from functions
      https://github.com/kvm-x86/linux/commit/2d30059d38e6
[2/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from iterators
      https://github.com/kvm-x86/linux/commit/59b93e634b40
[3/4] KVM: x86/mmu: always take tdp_mmu_pages_lock
      https://github.com/kvm-x86/linux/commit/4072c73104f2
[4/4] KVM: x86/mmu: fix comment about mmu_unsync_pages_lock
      https://github.com/kvm-x86/linux/commit/9dc2973a3b20

--
https://github.com/kvm-x86/linux/tree/next
Re: [PATCH v2 0/4] KVM: x86/mmu: small locking cleanups
Posted by Sean Christopherson 2 years ago
On Thu, Nov 30, 2023, Sean Christopherson wrote:
> On Sat, 25 Nov 2023 03:33:56 -0500, Paolo Bonzini wrote:
> > Remove "bool shared" argument from functions and iterators that need
> > not know if the lock is taken for read or write.  This is common because
> > protection is achieved via RCU and tdp_mmu_pages_lock or because the
> > argument is only used for assertions that can be written by hand.
> > 
> > Also always take tdp_mmu_pages_lock even if mmu_lock is currently taken
> > for write.
> > 
> > [...]
> 
> Applied to kvm-x86 mmu, thanks!
> 
> [1/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from functions
>       https://github.com/kvm-x86/linux/commit/2d30059d38e6
> [2/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from iterators
>       https://github.com/kvm-x86/linux/commit/59b93e634b40
> [3/4] KVM: x86/mmu: always take tdp_mmu_pages_lock
>       https://github.com/kvm-x86/linux/commit/4072c73104f2
> [4/4] KVM: x86/mmu: fix comment about mmu_unsync_pages_lock
>       https://github.com/kvm-x86/linux/commit/9dc2973a3b20

FYI, I had to force push to mmu to fixup an unrelated Fixes: issue, new hashes:

[1/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from functions
      https://github.com/kvm-x86/linux/commit/5f3c8c9187b6
[2/4] KVM: x86/mmu: remove unnecessary "bool shared" argument from iterators
      https://github.com/kvm-x86/linux/commit/484dd27c0602
[3/4] KVM: x86/mmu: always take tdp_mmu_pages_lock
      https://github.com/kvm-x86/linux/commit/250ce1b4d21a
[4/4] KVM: x86/mmu: fix comment about mmu_unsync_pages_lock
      https://github.com/kvm-x86/linux/commit/e59f75de4e50