All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add PLE stats to kvmstat
@ 2012-07-05 21:50 Andrew Theurer
  2012-07-06  7:42 ` Xiao Guangrong
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Theurer @ 2012-07-05 21:50 UTC (permalink / raw)
  To: kvm

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(-)


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;
 			}
 		}



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-05 21:50 [PATCH] add PLE stats to kvmstat Andrew Theurer
@ 2012-07-06  7:42 ` Xiao Guangrong
  2012-07-06 13:22   ` Andrew Theurer
  0 siblings, 1 reply; 8+ messages in thread
From: Xiao Guangrong @ 2012-07-06  7:42 UTC (permalink / raw)
  To: habanero; +Cc: kvm

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. :)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-06  7:42 ` Xiao Guangrong
@ 2012-07-06 13:22   ` Andrew Theurer
  2012-07-06 17:40     ` Xiao Guangrong
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Theurer @ 2012-07-06 13:22 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: kvm

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-06 13:22   ` Andrew Theurer
@ 2012-07-06 17:40     ` Xiao Guangrong
  2012-07-06 18:12       ` Andrew Theurer
  0 siblings, 1 reply; 8+ messages in thread
From: Xiao Guangrong @ 2012-07-06 17:40 UTC (permalink / raw)
  To: habanero; +Cc: Xiao Guangrong, kvm

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. :)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-06 17:40     ` Xiao Guangrong
@ 2012-07-06 18:12       ` Andrew Theurer
  2012-07-08  9:50         ` Avi Kivity
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Theurer @ 2012-07-06 18:12 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Xiao Guangrong, kvm

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-06 18:12       ` Andrew Theurer
@ 2012-07-08  9:50         ` Avi Kivity
  2012-07-09  6:42           ` Xiao Guangrong
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2012-07-08  9:50 UTC (permalink / raw)
  To: habanero; +Cc: Xiao Guangrong, Xiao Guangrong, kvm

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).

-- 
error compiling committee.c: too many arguments to function



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-08  9:50         ` Avi Kivity
@ 2012-07-09  6:42           ` Xiao Guangrong
  2012-07-09 10:52             ` Avi Kivity
  0 siblings, 1 reply; 8+ messages in thread
From: Xiao Guangrong @ 2012-07-09  6:42 UTC (permalink / raw)
  To: Avi Kivity; +Cc: habanero, Xiao Guangrong, kvm

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!




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] add PLE stats to kvmstat
  2012-07-09  6:42           ` Xiao Guangrong
@ 2012-07-09 10:52             ` Avi Kivity
  0 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2012-07-09 10:52 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: habanero, kvm

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.

-- 
error compiling committee.c: too many arguments to function



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-09 10:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-05 21:50 [PATCH] add PLE stats to kvmstat Andrew Theurer
2012-07-06  7:42 ` Xiao Guangrong
2012-07-06 13:22   ` Andrew Theurer
2012-07-06 17:40     ` Xiao Guangrong
2012-07-06 18:12       ` Andrew Theurer
2012-07-08  9:50         ` Avi Kivity
2012-07-09  6:42           ` Xiao Guangrong
2012-07-09 10:52             ` Avi Kivity

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.