Re: [PATCH 3/4 v2] KVM: nVMX: nSVM: Add a new debugfs statistic to show how many VCPUs have run nested guests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 20, 2021 at 7:56 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Wed, May 19, 2021, Krish Sadhukhan wrote:
> > Add a new debugfs statistic to show how many VCPUs have run nested guests.
> > This statistic considers only the first time a given VCPU successfully runs
> > a nested guest.
> >
> > Signed-off-by: Krish Sadhukhan <Krish.Sadhukhan@xxxxxxxxxx>
> > Suggested-by: Jim Mattson <jmattson@xxxxxxxxxx>
> > ---
> >  arch/x86/include/asm/kvm_host.h | 1 +
> >  arch/x86/kvm/svm/svm.c          | 5 ++++-
> >  arch/x86/kvm/vmx/vmx.c          | 5 ++++-
> >  arch/x86/kvm/x86.c              | 1 +
> >  4 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index cf8557b2b90f..a19fe2cfaa93 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -1138,6 +1138,7 @@ struct kvm_vm_stat {
> >       ulong lpages;
> >       ulong nx_lpage_splits;
> >       ulong max_mmu_page_hash_collisions;
> > +     ulong vcpus_ran_nested;
> >  };
> >
> >  struct kvm_vcpu_stat {
> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> > index 57c351640355..d1871c51411f 100644
> > --- a/arch/x86/kvm/svm/svm.c
> > +++ b/arch/x86/kvm/svm/svm.c
> > @@ -3876,8 +3876,11 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
> >               /* Track VMRUNs that have made past consistency checking */
> >               if (svm->nested.nested_run_pending &&
> >                   svm->vmcb->control.exit_code != SVM_EXIT_ERR &&
> > -                 svm->vmcb->control.exit_code != SVM_EXIT_NPF)
> > +                 svm->vmcb->control.exit_code != SVM_EXIT_NPF) {
> > +                     if (!vcpu->stat.nested_runs)
> > +                             ++vcpu->kvm->stat.vcpus_ran_nested;
>
> Using a separate counter seems unnecessary, userspace can aggregate
> vcpu->stat.nested_run itself to see how many vCPUs have done nested VM-Enter.
>
> Jim, were you thinking of something else?  Am I missing something?

It was in the context of a proposed stat to indicate how many vCPUs
are *currently* running nested guests that I said I'd rather just know
how many vCPUs had *ever* run nested guests. I don't need a separate
stat. Checking vcpu->stat.nested_run for non-zero values works fine
for me.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux