]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: pfncache: check the need for invalidation under read lock first
authorPaul Durrant <pdurrant@amazon.com>
Mon, 4 Dec 2023 10:41:39 +0000 (10:41 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Thu, 15 Feb 2024 09:56:16 +0000 (09:56 +0000)
commit951c1d82817d9076fbfd174e2c9012078cc0c6a8
tree9d5ae630978391b07e0f64b5edd24dadcb9dce63
parenta2adcd124ff47d4f1692f4ca4859e795fe771031
KVM: pfncache: check the need for invalidation under read lock first

When processing mmu_notifier invalidations for gpc caches, pre-check for
overlap with the invalidation event while holding gpc->lock for read, and
only take gpc->lock for write if the cache needs to be invalidated.  Doing
a pre-check without taking gpc->lock for write avoids unnecessarily
contending the lock for unrelated invalidations, which is very beneficial
for caches that are heavily used (but rarely subjected to mmu_notifier
invalidations).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
---
Cc: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
v13:
 - Use Sean's preferred wording for the commit comment.

v10:
 - New in this version.
virt/kvm/pfncache.c