lkml.org 
[lkml]   [2021]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 07/13] KVM: x86/mmu: Make TDP MMU root refcount atomic
    On Wed, Mar 31, 2021, Ben Gardon wrote:
    > In order to parallelize more operations for the TDP MMU, make the
    > refcount on TDP MMU roots atomic, so that a future patch can allow
    > multiple threads to take a reference on the root concurrently, while
    > holding the MMU lock in read mode.
    >
    > Signed-off-by: Ben Gardon <bgardon@google.com>
    > ---

    ...

    > @@ -88,10 +88,12 @@ static struct kvm_mmu_page *tdp_mmu_next_root(struct kvm *kvm,
    > next_root = list_first_entry(&kvm->arch.tdp_mmu_roots,
    > typeof(*next_root), link);
    >
    > + while (!list_entry_is_head(next_root, &kvm->arch.tdp_mmu_roots, link) &&
    > + !kvm_tdp_mmu_get_root(kvm, next_root))
    > + next_root = list_next_entry(next_root, link);
    > +
    > if (list_entry_is_head(next_root, &kvm->arch.tdp_mmu_roots, link))
    > next_root = NULL;
    > - else
    > - kvm_tdp_mmu_get_root(kvm, next_root);
    >
    > if (prev_root)
    > kvm_tdp_mmu_put_root(kvm, prev_root);
    > @@ -158,14 +160,13 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(struct kvm_vcpu *vcpu)
    >
    > /* Check for an existing root before allocating a new one. */
    > for_each_tdp_mmu_root(kvm, root) {
    > - if (root->role.word == role.word) {
    > - kvm_tdp_mmu_get_root(kvm, root);
    > + if (root->role.word == role.word &&
    > + kvm_tdp_mmu_get_root(kvm, root))

    I'm not opposed to changing this logic while making the refcount atomic, but it
    needs to be explained in the changelog. As is, the changelog makes it sound
    like the patch is a pure refactoring of the type.

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