[PATCH 1/7] KVM: arm64: Add two page mapping counters for kvm_stat
Keqian Zhu
zhukeqian1 at huawei.com
Tue Mar 23 11:52:38 GMT 2021
Hi Yoan,
On 2021/3/20 0:17, Yoan Picchi wrote:
> Add a counter for when a regular page is mapped, and another
> for when a huge page is mapped.
>
> Signed-off-by: Yoan Picchi <yoan.picchi at arm.com>
> ---
> arch/arm64/include/asm/kvm_host.h | 2 ++
> arch/arm64/kvm/guest.c | 2 ++
> arch/arm64/kvm/mmu.c | 7 +++++++
> 3 files changed, 11 insertions(+)
>
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 3d10e6527..863603285 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -561,6 +561,8 @@ struct kvm_vcpu_stat {
> u64 wfi_exit_stat;
> u64 mmio_exit_user;
> u64 mmio_exit_kernel;
> + u64 regular_page_mapped;
> + u64 huge_page_mapped;
> u64 exits;
> };
>
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index 9bbd30e62..14b15fb8f 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -38,6 +38,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
> VCPU_STAT("wfi_exit_stat", wfi_exit_stat),
> VCPU_STAT("mmio_exit_user", mmio_exit_user),
> VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel),
> + VCPU_STAT("regular_page_mapped", regular_page_mapped),
> + VCPU_STAT("huge_page_mapped", huge_page_mapped),
> VCPU_STAT("exits", exits),
> VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns),
> VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns),
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 77cb2d28f..3996b28da 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -914,6 +914,13 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> mark_page_dirty(kvm, gfn);
> }
>
> + if (ret >= 0) {
> + if (vma_pagesize == PAGE_SIZE) {
> + vcpu->stat.regular_page_mapped++;
> + } else {
> + vcpu->stat.huge_page_mapped++;
> + }
> + }
This looks too simple, as we don't always map a new regular_page or huge_page here.
We may just relax permission or change mapping size, etc. If we mix these operations,
the stat result seems not very valuable...
Thanks,
Keqian
> out_unlock:
> spin_unlock(&kvm->mmu_lock);
> kvm_set_pfn_accessed(pfn);
>
More information about the linux-arm-kernel
mailing list