diff mbox

add PLE stats to kvmstat

Message ID 1341525037.12425.46.camel@oc2024037011.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Theurer July 5, 2012, 9:50 p.m. UTC
I, and I expect others, have a keen interest in knowing how often we
exit for PLE, and also how often that includes a yielding to another
vcpu.  The following adds two more counters to kvmstat to track the
exits and the vcpu yields.  This in no way changes PLE behavior, just
helps us track what's going on.

-Andrew Theurer

Signed-off-by: Andrew Theurer <habanero@linux.vnet.ibm.com>

 arch/x86/include/asm/kvm_host.h |    2 ++
 arch/x86/kvm/svm.c              |    1 +
 arch/x86/kvm/vmx.c              |    1 +
 arch/x86/kvm/x86.c              |    2 ++
 virt/kvm/kvm_main.c             |    1 +
 5 files changed, 7 insertions(+), 0 deletions(-)




--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Xiao Guangrong July 6, 2012, 7:42 a.m. UTC | #1
On 07/06/2012 05:50 AM, Andrew Theurer wrote:
> I, and I expect others, have a keen interest in knowing how often we
> exit for PLE, and also how often that includes a yielding to another
> vcpu.  The following adds two more counters to kvmstat to track the
> exits and the vcpu yields.  This in no way changes PLE behavior, just
> helps us track what's going on.
> 

Tracepoint is a better choice than the counters you used. :)

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Theurer July 6, 2012, 1:22 p.m. UTC | #2
On Fri, 2012-07-06 at 15:42 +0800, Xiao Guangrong wrote:
> On 07/06/2012 05:50 AM, Andrew Theurer wrote:
> > I, and I expect others, have a keen interest in knowing how often we
> > exit for PLE, and also how often that includes a yielding to another
> > vcpu.  The following adds two more counters to kvmstat to track the
> > exits and the vcpu yields.  This in no way changes PLE behavior, just
> > helps us track what's going on.
> > 
> 
> Tracepoint is a better choice than the counters you used. :)

Xiao, is kvmstat considered to be deprecated?  Or are debug stats like
this just generally favored to be processed via something like perf
instead of debugfs?  Should we be removing kvmstat?

Thanks,

-Andrew Theurer

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong July 6, 2012, 5:40 p.m. UTC | #3
On 07/06/2012 09:22 PM, Andrew Theurer wrote:
> On Fri, 2012-07-06 at 15:42 +0800, Xiao Guangrong wrote:
>> On 07/06/2012 05:50 AM, Andrew Theurer wrote:
>>> I, and I expect others, have a keen interest in knowing how often we
>>> exit for PLE, and also how often that includes a yielding to another
>>> vcpu.  The following adds two more counters to kvmstat to track the
>>> exits and the vcpu yields.  This in no way changes PLE behavior, just
>>> helps us track what's going on.
>>>
>>
>> Tracepoint is a better choice than the counters you used. :)
> 
> Xiao, is kvmstat considered to be deprecated?  Or are debug stats like
> this just generally favored to be processed via something like perf
> instead of debugfs?

Andrew, please refer to Documentation/feature-removal-schedule.txt,
it says:

What:   KVM debugfs statistics
When:   2013
Why:    KVM tracepoints provide mostly equivalent information in a much more
        flexible fashion.

You can use tracepoints instead of your debugfs-counters in this patch.

>  Should we be removing kvmstat?
> 

Some months ago, i implemented 'perf kvm-events' which can analyse kvm
events more smartly, the patchset can be found at:
	https://lkml.org/lkml/2012/3/6/86

Avi said it may instead of kvmstat, but i am too busy to update this
patchset. :)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Theurer July 6, 2012, 6:12 p.m. UTC | #4
On Sat, 2012-07-07 at 01:40 +0800, Xiao Guangrong wrote:
> On 07/06/2012 09:22 PM, Andrew Theurer wrote:
> > On Fri, 2012-07-06 at 15:42 +0800, Xiao Guangrong wrote:
> >> On 07/06/2012 05:50 AM, Andrew Theurer wrote:
> >>> I, and I expect others, have a keen interest in knowing how often we
> >>> exit for PLE, and also how often that includes a yielding to another
> >>> vcpu.  The following adds two more counters to kvmstat to track the
> >>> exits and the vcpu yields.  This in no way changes PLE behavior, just
> >>> helps us track what's going on.
> >>>
> >>
> >> Tracepoint is a better choice than the counters you used. :)
> > 
> > Xiao, is kvmstat considered to be deprecated?  Or are debug stats like
> > this just generally favored to be processed via something like perf
> > instead of debugfs?
> 
> Andrew, please refer to Documentation/feature-removal-schedule.txt,
> it says:
> 
> What:   KVM debugfs statistics
> When:   2013
> Why:    KVM tracepoints provide mostly equivalent information in a much more
>         flexible fashion.
> 
> You can use tracepoints instead of your debugfs-counters in this patch.

Great, thanks.  I will work on a tracepoint based approach.
> 
> >  Should we be removing kvmstat?
> > 
> 
> Some months ago, i implemented 'perf kvm-events' which can analyse kvm
> events more smartly, the patchset can be found at:
> 	https://lkml.org/lkml/2012/3/6/86

I will take a look.
> 
> Avi said it may instead of kvmstat, but i am too busy to update this
> patchset. :)
> 

-Andrew


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity July 8, 2012, 9:50 a.m. UTC | #5
On 07/06/2012 09:12 PM, Andrew Theurer wrote:
> On Sat, 2012-07-07 at 01:40 +0800, Xiao Guangrong wrote:
>> On 07/06/2012 09:22 PM, Andrew Theurer wrote:
>> > On Fri, 2012-07-06 at 15:42 +0800, Xiao Guangrong wrote:
>> >> On 07/06/2012 05:50 AM, Andrew Theurer wrote:
>> >>> I, and I expect others, have a keen interest in knowing how often we
>> >>> exit for PLE, and also how often that includes a yielding to another
>> >>> vcpu.  The following adds two more counters to kvmstat to track the
>> >>> exits and the vcpu yields.  This in no way changes PLE behavior, just
>> >>> helps us track what's going on.
>> >>>
>> >>
>> >> Tracepoint is a better choice than the counters you used. :)
>> > 
>> > Xiao, is kvmstat considered to be deprecated?  Or are debug stats like
>> > this just generally favored to be processed via something like perf
>> > instead of debugfs?
>> 
>> Andrew, please refer to Documentation/feature-removal-schedule.txt,
>> it says:
>> 
>> What:   KVM debugfs statistics
>> When:   2013
>> Why:    KVM tracepoints provide mostly equivalent information in a much more
>>         flexible fashion.
>> 
>> You can use tracepoints instead of your debugfs-counters in this patch.
> 
> Great, thanks.  I will work on a tracepoint based approach.
>> 
>> >  Should we be removing kvmstat?
>> > 
>> 
>> Some months ago, i implemented 'perf kvm-events' which can analyse kvm
>> events more smartly, the patchset can be found at:
>> 	https://lkml.org/lkml/2012/3/6/86
> 
> I will take a look.
>> 
>> Avi said it may instead of kvmstat, but i am too busy to update this
>> patchset. :)
>> 

Note, kvm_stat is able to use both the old debugfs based statistics and
the tracepoint based events.  The latter requires root privileges.

(bonus: pressing 'x' expands the kvm_exit statistic to include
information about the various hardware exit reasons).
Xiao Guangrong July 9, 2012, 6:42 a.m. UTC | #6
On 07/08/2012 05:50 PM, Avi Kivity wrote:
> On 07/06/2012 09:12 PM, Andrew Theurer wrote:
>> On Sat, 2012-07-07 at 01:40 +0800, Xiao Guangrong wrote:
>>> On 07/06/2012 09:22 PM, Andrew Theurer wrote:
>>>> On Fri, 2012-07-06 at 15:42 +0800, Xiao Guangrong wrote:
>>>>> On 07/06/2012 05:50 AM, Andrew Theurer wrote:
>>>>>> I, and I expect others, have a keen interest in knowing how often we
>>>>>> exit for PLE, and also how often that includes a yielding to another
>>>>>> vcpu.  The following adds two more counters to kvmstat to track the
>>>>>> exits and the vcpu yields.  This in no way changes PLE behavior, just
>>>>>> helps us track what's going on.
>>>>>>
>>>>>
>>>>> Tracepoint is a better choice than the counters you used. :)
>>>>
>>>> Xiao, is kvmstat considered to be deprecated?  Or are debug stats like
>>>> this just generally favored to be processed via something like perf
>>>> instead of debugfs?
>>>
>>> Andrew, please refer to Documentation/feature-removal-schedule.txt,
>>> it says:
>>>
>>> What:   KVM debugfs statistics
>>> When:   2013
>>> Why:    KVM tracepoints provide mostly equivalent information in a much more
>>>         flexible fashion.
>>>
>>> You can use tracepoints instead of your debugfs-counters in this patch.
>>
>> Great, thanks.  I will work on a tracepoint based approach.
>>>
>>>>  Should we be removing kvmstat?
>>>>
>>>
>>> Some months ago, i implemented 'perf kvm-events' which can analyse kvm
>>> events more smartly, the patchset can be found at:
>>> 	https://lkml.org/lkml/2012/3/6/86
>>
>> I will take a look.
>>>
>>> Avi said it may instead of kvmstat, but i am too busy to update this
>>> patchset. :)
>>>
> 
> Note, kvm_stat is able to use both the old debugfs based statistics and
> the tracepoint based events.  The latter requires root privileges.
> 

Yes, but you are going to remove KVM debugfs statistics, will you
plan to remove kvm_stat after debugfs based statistics removed and
kvm-events merged?

> (bonus: pressing 'x' expands the kvm_exit statistic to include
> information about the various hardware exit reasons).

Yes, i noticed that, good feature, thank you, Avi!



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity July 9, 2012, 10:52 a.m. UTC | #7
On 07/09/2012 09:42 AM, Xiao Guangrong wrote:
>> 
>> Note, kvm_stat is able to use both the old debugfs based statistics and
>> the tracepoint based events.  The latter requires root privileges.
>> 
> 
> Yes, but you are going to remove KVM debugfs statistics, will you
> plan to remove kvm_stat after debugfs based statistics removed and
> kvm-events merged?

Probably not for a while, it will still be useful for older kernels.
diff mbox

Patch

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 24b7647..aebba8a 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -593,6 +593,8 @@  struct kvm_vcpu_stat {
 	u32 hypercalls;
 	u32 irq_injections;
 	u32 nmi_injections;
+	u32 pause_exits;
+	u32 vcpu_yield_to;
 };
 
 struct x86_instruction_info;
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 7a41878..1c1b81e 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3264,6 +3264,7 @@  static int interrupt_window_interception(struct vcpu_svm *svm)
 
 static int pause_interception(struct vcpu_svm *svm)
 {
+	++svm->vcpu.stat.pause_exits;
 	kvm_vcpu_on_spin(&(svm->vcpu));
 	return 1;
 }
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index eeeb4a2..1309578 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5004,6 +5004,7 @@  out:
  */
 static int handle_pause(struct kvm_vcpu *vcpu)
 {
+	++vcpu->stat.pause_exits;
 	skip_emulated_instruction(vcpu);
 	kvm_vcpu_on_spin(vcpu);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8eacb2e..ad85403 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -143,6 +143,8 @@  struct kvm_stats_debugfs_item debugfs_entries[] = {
 	{ "insn_emulation_fail", VCPU_STAT(insn_emulation_fail) },
 	{ "irq_injections", VCPU_STAT(irq_injections) },
 	{ "nmi_injections", VCPU_STAT(nmi_injections) },
+	{ "pause_exits", VCPU_STAT(pause_exits) },
+	{ "vcpu_yield_to", VCPU_STAT(vcpu_yield_to) },
 	{ "mmu_shadow_zapped", VM_STAT(mmu_shadow_zapped) },
 	{ "mmu_pte_write", VM_STAT(mmu_pte_write) },
 	{ "mmu_pte_updated", VM_STAT(mmu_pte_updated) },
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 636bd08..d80b6cd 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1610,6 +1610,7 @@  void kvm_vcpu_on_spin(struct kvm_vcpu *me)
 			if (kvm_vcpu_yield_to(vcpu)) {
 				kvm->last_boosted_vcpu = i;
 				yielded = 1;
+				++vcpu->stat.vcpu_yield_to;
 				break;
 			}
 		}