lkml.org 
[lkml]   [2021]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 08/13] KVM: x86/mmu: Protect the tdp_mmu_roots list with RCU
From
Date
On 31/03/21 23:08, Ben Gardon wrote:
> Protect the contents of the TDP MMU roots list with RCU in preparation
> for a future patch which will allow the iterator macro to be used under
> the MMU lock in read mode.
>
> Signed-off-by: Ben Gardon<bgardon@google.com>
> ---
> arch/x86/kvm/mmu/tdp_mmu.c | 64 +++++++++++++++++++++-----------------
> 1 file changed, 36 insertions(+), 28 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> + spin_lock(&kvm->arch.tdp_mmu_pages_lock);
> + list_del_rcu(&root->link);
> + spin_unlock(&kvm->arch.tdp_mmu_pages_lock);


Please update the comment above tdp_mmu_pages_lock in
arch/x86/include/asm/kvm_host.h as well.

> /* Only safe under the MMU lock in write mode, without yielding. */
> #define for_each_tdp_mmu_root(_kvm, _root) \
> - list_for_each_entry(_root, &_kvm->arch.tdp_mmu_roots, link)
> + list_for_each_entry_rcu(_root, &_kvm->arch.tdp_mmu_roots, link, \
> + lockdep_is_held_write(&kvm->mmu_lock))

This should also add "... ||
lockdep_is_help(&kvm->arch.tdp_mmu_pages_lock)", if only for
documentation purposes.

Paolo

\
 
 \ /
  Last update: 2021-04-01 11:38    [W:0.225 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site