From: Christoffer Dall <christoffer.dall@linaro.org>
To: Amit <amittomer25@gmail.com>
Cc: marc.zyngier@arm.com, andre.przywara@arm.com,
kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH] KVM: arm64: Count guest exit due to various reasons
Date: Thu, 22 Oct 2015 23:16:01 +0200 [thread overview]
Message-ID: <20151022211601.GA25602@cbox> (raw)
In-Reply-To: <1445155482-12482-1-git-send-email-amittomer25@gmail.com>
On Sun, Oct 18, 2015 at 01:34:42PM +0530, Amit wrote:
> From: Amit Singh Tomar <amittomer25@gmail.com>
>
> This patch adds guest exit statistics to debugfs, This can be helpful
> while measuring KVM performance.
>
> Signed-off-by: Amit Singh Tomar <amittomer25@gmail.com>
> ---
> arch/arm/include/asm/kvm_host.h | 2 ++
> arch/arm/kvm/arm.c | 1 +
> arch/arm/kvm/guest.c | 2 ++
> arch/arm/kvm/mmio.c | 1 +
> arch/arm64/include/asm/kvm_host.h | 5 +++++
> arch/arm64/kvm/guest.c | 8 ++++++++
> arch/arm64/kvm/handle_exit.c | 3 +++
> 7 files changed, 22 insertions(+)
>
> diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
> index c4072d9..d1f3159 100644
> --- a/arch/arm/include/asm/kvm_host.h
> +++ b/arch/arm/include/asm/kvm_host.h
> @@ -147,6 +147,8 @@ struct kvm_vcpu_stat {
> u32 halt_successful_poll;
> u32 halt_attempted_poll;
> u32 halt_wakeup;
> + u32 mmio_exit_stat;
I think it would be even more useful to distinguish between mmio exits
handled in the kernel vs. those going to userspace.
> + u32 exits;
> };
>
> int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index 78b2869..5d0a2c5 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -569,6 +569,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
> ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
>
> vcpu->mode = OUTSIDE_GUEST_MODE;
> + vcpu->stat.exits++;
> /*
> * Back from guest
> *************************************************************/
> diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c
> index 96e935b..0eea5fc 100644
> --- a/arch/arm/kvm/guest.c
> +++ b/arch/arm/kvm/guest.c
> @@ -33,6 +33,8 @@
> #define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU }
>
> struct kvm_stats_debugfs_item debugfs_entries[] = {
> + VCPU_STAT(mmio_exit_stat),
> + VCPU_STAT(exits),
> { NULL }
> };
>
> diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
> index 974b1c6..51d518e 100644
> --- a/arch/arm/kvm/mmio.c
> +++ b/arch/arm/kvm/mmio.c
> @@ -184,6 +184,7 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
> }
>
> rt = vcpu->arch.mmio_decode.rt;
> + vcpu->stat.mmio_exit_stat++;
>
> if (is_write) {
> data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt), len);
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index ed03968..b32c938 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -194,6 +194,11 @@ struct kvm_vcpu_stat {
> u32 halt_successful_poll;
> u32 halt_attempted_poll;
> u32 halt_wakeup;
> + u32 hvc_exit_stat;
> + u32 wfx_exit_stat;
> + u32 wfi_exit_stat;
> + u32 mmio_exit_stat;
> + u32 exits;
why more exit stats on arm64 than on arm?
why u32? Would it not make sense to make these u64 or just unsigned
long?
> };
>
> int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index d250160..b1943cd 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -34,7 +34,15 @@
>
> #include "trace.h"
>
> +#define VM_STAT(x) { #x, offsetof(struct kvm, stat.x), KVM_STAT_VM }
> +#define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU }
> +
> struct kvm_stats_debugfs_item debugfs_entries[] = {
> + VCPU_STAT(hvc_exit_stat),
> + VCPU_STAT(wfx_exit_stat),
> + VCPU_STAT(wfi_exit_stat),
> + VCPU_STAT(mmio_exit_stat),
> + VCPU_STAT(exits),
> { NULL }
> };
>
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index 68a0759..6e38c50 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -39,6 +39,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)
>
> trace_kvm_hvc_arm64(*vcpu_pc(vcpu), *vcpu_reg(vcpu, 0),
> kvm_vcpu_hvc_get_imm(vcpu));
> + vcpu->stat.hvc_exit_stat++;
>
> ret = kvm_psci_call(vcpu);
> if (ret < 0) {
> @@ -71,9 +72,11 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
> {
> if (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE) {
> trace_kvm_wfx_arm64(*vcpu_pc(vcpu), true);
> + vcpu->stat.wfx_exit_stat++;
either you should use one called wfx_exit_stat or you should distinguish
between wfi and wfe; this is just a weird way of doing it.
> kvm_vcpu_on_spin(vcpu);
> } else {
> trace_kvm_wfx_arm64(*vcpu_pc(vcpu), false);
> + vcpu->stat.wfi_exit_stat++;
> kvm_vcpu_block(vcpu);
> }
>
> --
> 1.9.1
>
Thanks,
-Christoffer
next prev parent reply other threads:[~2015-10-22 21:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-18 8:04 [PATCH] KVM: arm64: Count guest exit due to various reasons Amit
2015-10-18 19:53 ` Christoffer Dall
2015-10-20 5:17 ` Wei Huang
2015-10-22 21:16 ` Christoffer Dall [this message]
2015-10-26 12:14 ` Amit Tomer
2015-10-26 15:44 ` Christoffer Dall
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=20151022211601.GA25602@cbox \
--to=christoffer.dall@linaro.org \
--cc=amittomer25@gmail.com \
--cc=andre.przywara@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox