From: Ackerley Tng Clarify the existing comment about synchronize_srcu() and kvm_gmem_get_pfn() to provide further context. Explain which synchronize_srcu() prevents races with how kvm_gmem_get_pfn() is used. Also point reader to documentation for better understanding. Signed-off-by: Ackerley Tng --- virt/kvm/guest_memfd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index 69c9d6d546b28..f2218db0af980 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -711,8 +711,13 @@ static void __kvm_gmem_unbind(struct kvm_memory_slot *slot, struct gmem_file *f) xa_store_range(&f->bindings, start, end - 1, NULL, GFP_KERNEL); /* - * synchronize_srcu(&kvm->srcu) ensured that kvm_gmem_get_pfn() - * cannot see this memslot. + * This is called when memslots are updated, after the old + * memslot container is no longer in + * use. synchronize_srcu(&kvm->srcu) was called there, so + * kvm_gmem_get_pfn() from KVM's guest fault handling cannot + * see this memslot. See Documentation/virt/kvm/locking.rst + * for more information about kvm->srcu and the memslots + * container. */ WRITE_ONCE(slot->gmem.file, NULL); } -- 2.54.0.823.g6e5bcc1fc9-goog