Thread (19 messages) flat view 19 messages, 2 authors, 14d ago

Re: [PATCH RFC 02/10] KVM: Allow reading memslots while holding slots_arch_lock

From: Marco Elver <elver@google.com>
Date: 2026-09-10 17:18:10
Also in: kvm, lkml

On Thu, 10 Sept 2026 at 18:30, Sean Christopherson [off-list ref] wrote:
On Thu, Sep 10, 2026, Marco Elver wrote:
quoted
kvm_swap_active_memslots() updates kvm->memslots[as_id] while holding both
kvm->slots_lock and kvm->slots_arch_lock. Holding either lock guarantees
that memslots cannot be concurrently modified.
Sure, but that's irrelevant.  The goal of the srcu_dereference_check() is to
ensure that readers see a stable view of the VM's overall memory, not simply that
kvm->memslots can't be written.
Functionally, this is irrelevant for readers. But under lockdep it
isn't for writers: srcu_dereference_check() (with lockdep) asserts
that the srcu reader-lock is held, or the condition 'c' holds, which
here is holding any of the writer locks.
quoted
Allow reading memslots in __kvm_memslots() when kvm->slots_arch_lock is
held.
Why?
Holding any of the writer locks guarantees no concurrent modification;
therefore, if any writer lock is held, it's not required that the srcu
reader-lock is held. There are few places where only either slots_lock
or slots_arch_lock is held, which is sufficient for reading.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help