[PATCH RFC 02/12] Documentation: KVM: Consolidate notes about cpu_read_lock() and kvm_lock
From: Ackerley Tng via B4 Relay
Date: Wed May 27 2026 - 11:36:17 EST
From: Ackerley Tng <ackerleytng@xxxxxxxxxx>
Move the detail about cpu_read_lock() and kvm_lock to where the acquisition
order is mentioned.
Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
---
Documentation/virt/kvm/locking.rst | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/Documentation/virt/kvm/locking.rst b/Documentation/virt/kvm/locking.rst
index 5564c8b38b9cc..1e8cbbe3ba706 100644
--- a/Documentation/virt/kvm/locking.rst
+++ b/Documentation/virt/kvm/locking.rst
@@ -10,6 +10,11 @@ KVM Lock Overview
The acquisition orders for mutexes are as follows:
- cpus_read_lock() is taken outside kvm_lock
+ - Taking cpus_read_lock() outside of kvm_lock is problematic,
+ despite it being the official ordering, as it is quite easy to
+ unknowingly trigger cpus_read_lock() while holding kvm_lock.
+ Use caution when walking vm_list, e.g. avoid complex operations
+ when possible.
- kvm_usage_lock is taken outside cpus_read_lock()
@@ -28,13 +33,6 @@ The acquisition orders for mutexes are as follows:
are taken on the waiting side when modifying memslots, so MMU notifiers
must not take either kvm->slots_lock or kvm->slots_arch_lock.
-cpus_read_lock() vs kvm_lock:
-
-- Taking cpus_read_lock() outside of kvm_lock is problematic, despite that
- being the official ordering, as it is quite easy to unknowingly trigger
- cpus_read_lock() while holding kvm_lock. Use caution when walking vm_list,
- e.g. avoid complex operations when possible.
-
For SRCU:
- ``synchronize_srcu(&kvm->srcu)`` is called inside critical sections
--
2.54.0.823.g6e5bcc1fc9-goog