All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: Jim Mattson <jmattson@google.com>,
	Sean Christopherson <seanjc@google.com>
Cc: kvm list <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 3/4 v2] KVM: nVMX: nSVM: Add a new debugfs statistic to show how many VCPUs have run nested guests
Date: Thu, 20 May 2021 11:01:28 -0700	[thread overview]
Message-ID: <c4221011-1936-15cc-9eb1-054a585d25b9@oracle.com> (raw)
In-Reply-To: <CALMp9eT+Sj4=tQZJaeLfJALkeUbo=jiTmM-CQ71z5aOhD6MMiw@mail.gmail.com>


On 5/20/21 9:57 AM, Jim Mattson wrote:
> On Thu, May 20, 2021 at 7:56 AM Sean Christopherson <seanjc@google.com> 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@oracle.com>
>>> Suggested-by: Jim Mattson <jmattson@google.com>
>>> ---
>>>   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.
I will fall back to my v1 idea then. That's at least useful if we want 
to create a time graph of VCPUs running nested guests.

  reply	other threads:[~2021-05-20 18:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  0:50 [PATCH 0/4 v2] KVM: nVMX: nSVM: Add more statistics to KVM debugfs Krish Sadhukhan
2021-05-20  0:50 ` [PATCH 1/4 v2] KVM: nVMX: Reset 'nested_run_pending' only in guest mode Krish Sadhukhan
2021-05-20 15:00   ` Sean Christopherson
2021-05-20  0:50 ` [PATCH 2/4 v2] KVM: nVMX: nSVM: 'nested_run' should count guest-entry attempts that make it to guest code Krish Sadhukhan
2021-05-20 14:53   ` Sean Christopherson
2021-05-20 17:58     ` Krish Sadhukhan
2021-05-20  0:50 ` [PATCH 3/4 v2] KVM: nVMX: nSVM: Add a new debugfs statistic to show how many VCPUs have run nested guests Krish Sadhukhan
2021-05-20 14:56   ` Sean Christopherson
2021-05-20 16:57     ` Jim Mattson
2021-05-20 18:01       ` Krish Sadhukhan [this message]
2021-05-20  0:50 ` [PATCH 4/4 v2] KVM: x86: Add a new VM statistic to show number of VCPUs created in a given VM Krish Sadhukhan
2021-05-20 15:04   ` Sean Christopherson
2021-05-21 18:06     ` Krish Sadhukhan
2021-05-27 17:46       ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4221011-1936-15cc-9eb1-054a585d25b9@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.