Unverified Commit 74df1e70 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4802 Export vcpu stat via debugfs

Merge Pull Request from: @ci-robot 
 
PR sync from: liangtian <liangtian13@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/7S42O2S4ANYLGXBVPDHZD53BBJNPFIQE/ 
Create debugfs entry for vcpu stat.

chenjiajun (6):
  kvm: debugfs: Export vcpu stat via debugfs
  kvm: debugfs: export remaining aarch64 kvm exit reasons to debugfs
  kvm: debugfs: aarch64 export cpu time related items to debugfs
  kvm: debugfs: Export x86 kvm exits to vcpu_stat
  kvm: debugfs: add fastpath msr_wr exits to debugfs statistics
  kvm: debugfs: add EXIT_REASON_PREEMPTION_TIMER to vcpu_stat


-- 
2.33.0
 
https://gitee.com/openeuler/kernel/issues/I919BF 
 
Link:https://gitee.com/openeuler/kernel/pulls/4802

 

Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Reviewed-by: default avatarKevin Zhu <zhukeqian1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents f585a667 f9d0c531
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7704,6 +7704,7 @@ CONFIG_BTREE=y
CONFIG_INTERVAL_TREE=y
CONFIG_INTERVAL_TREE_SPAN_ITER=y
CONFIG_XARRAY_MULTI=y
CONFIG_ARCH_VCPU_STAT=y
CONFIG_ASSOCIATIVE_ARRAY=y
CONFIG_HAS_IOMEM=y
CONFIG_HAS_IOPORT=y
+21 −0
Original line number Diff line number Diff line
@@ -910,6 +910,7 @@ struct kvm_vm_stat {
};

struct kvm_vcpu_stat {
	u64 pid;
	struct kvm_vcpu_stat_generic generic;
	u64 hvc_exit_stat;
	u64 wfe_exit_stat;
@@ -918,6 +919,26 @@ struct kvm_vcpu_stat {
	u64 mmio_exit_kernel;
	u64 signal_exits;
	u64 exits;
	u64 fp_asimd_exit_stat;
	u64 irq_exit_stat;
	u64 sys64_exit_stat;
	u64 mabt_exit_stat;
	u64 fail_entry_exit_stat;
	u64 internal_error_exit_stat;
	u64 unknown_ec_exit_stat;
	u64 cp15_32_exit_stat;
	u64 cp15_64_exit_stat;
	u64 cp14_mr_exit_stat;
	u64 cp14_ls_exit_stat;
	u64 cp14_64_exit_stat;
	u64 smc_exit_stat;
	u64 sve_exit_stat;
	u64 debug_exit_stat;
	u64 steal;
	u64 st_max;
	u64 utime;
	u64 stime;
	u64 gtime;
};

unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
+9 −0
Original line number Diff line number Diff line
@@ -72,4 +72,13 @@ config PROTECTED_NVHE_STACKTRACE

	  If unsure, or not using protected nVHE (pKVM), say N.

config ARCH_VCPU_STAT
	bool "export kvm exits to vcpu_stat"
	depends on KVM
	default n
	help
	  Say Y here to enable kvm exits counting

	  If unsure, say N.

endif # VIRTUALIZATION
+31 −0
Original line number Diff line number Diff line
@@ -449,6 +449,22 @@ void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu)

}

#ifdef CONFIG_ARCH_VCPU_STAT
void kvm_arch_vcpu_stat_reset(struct kvm_vcpu_stat *vcpu_stat)
{
	vcpu_stat->st_max = 0;
}

static void update_steal_time(struct kvm_vcpu *vcpu)
{
	u64 delta;

	delta = current->sched_info.run_delay - vcpu->stat.steal;
	vcpu->stat.steal = current->sched_info.run_delay;
	vcpu->stat.st_max = max(vcpu->stat.st_max, delta);
}
#endif

void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{
	struct kvm_s2_mmu *mmu;
@@ -487,6 +503,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
	else
		vcpu_set_wfx_traps(vcpu);

#ifdef CONFIG_ARCH_VCPU_STAT
	update_steal_time(vcpu);
#endif
	if (vcpu_has_ptrauth(vcpu))
		vcpu_ptrauth_disable(vcpu);
	kvm_arch_vcpu_load_debug_state_flags(vcpu);
@@ -863,6 +882,15 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu)
	return !kvm_supports_32bit_el0();
}

#ifdef CONFIG_ARCH_VCPU_STAT
static void update_vcpu_stat_time(struct kvm_vcpu_stat *vcpu_stat)
{
	vcpu_stat->utime = current->utime;
	vcpu_stat->stime = current->stime;
	vcpu_stat->gtime = current->gtime;
}
#endif

/**
 * kvm_vcpu_exit_request - returns true if the VCPU should *not* enter the guest
 * @vcpu:	The VCPU pointer
@@ -1107,6 +1135,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
		}

		ret = handle_exit(vcpu, ret);
#ifdef CONFIG_ARCH_VCPU_STAT
		update_vcpu_stat_time(&vcpu->stat);
#endif
	}

	/* Tell userspace about in-kernel device output levels */
+39 −1
Original line number Diff line number Diff line
@@ -29,6 +29,41 @@

#include "trace.h"

#ifdef CONFIG_ARCH_VCPU_STAT
/* debugfs entries of Detail For vcpu stat EXtension */
struct dfx_kvm_stats_debugfs_item dfx_debugfs_entries[] = {
	DFX_STAT("pid", pid),
	DFX_STAT("hvc_exit_stat", hvc_exit_stat),
	DFX_STAT("wfe_exit_stat", wfe_exit_stat),
	DFX_STAT("wfi_exit_stat", wfi_exit_stat),
	DFX_STAT("mmio_exit_user", mmio_exit_user),
	DFX_STAT("mmio_exit_kernel", mmio_exit_kernel),
	DFX_STAT("signal_exits", signal_exits),
	DFX_STAT("exits", exits),
	DFX_STAT("fp_asimd_exit_stat", fp_asimd_exit_stat),
	DFX_STAT("irq_exit_stat", irq_exit_stat),
	DFX_STAT("sys64_exit_stat", sys64_exit_stat),
	DFX_STAT("mabt_exit_stat", mabt_exit_stat),
	DFX_STAT("fail_entry_exit_stat", fail_entry_exit_stat),
	DFX_STAT("internal_error_exit_stat", internal_error_exit_stat),
	DFX_STAT("unknown_ec_exit_stat", unknown_ec_exit_stat),
	DFX_STAT("cp15_32_exit_stat", cp15_32_exit_stat),
	DFX_STAT("cp15_64_exit_stat", cp15_64_exit_stat),
	DFX_STAT("cp14_mr_exit_stat", cp14_mr_exit_stat),
	DFX_STAT("cp14_ls_exit_stat", cp14_ls_exit_stat),
	DFX_STAT("cp14_64_exit_stat", cp14_64_exit_stat),
	DFX_STAT("smc_exit_stat", smc_exit_stat),
	DFX_STAT("sve_exit_stat", sve_exit_stat),
	DFX_STAT("debug_exit_stat", debug_exit_stat),
	DFX_STAT("steal", steal),
	DFX_STAT("st_max", st_max),
	DFX_STAT("utime", utime),
	DFX_STAT("stime", stime),
	DFX_STAT("gtime", gtime),
	{ NULL }
};
#endif

const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
	KVM_GENERIC_VM_STATS()
};
@@ -50,7 +85,10 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
	STATS_DESC_COUNTER(VCPU, mmio_exit_user),
	STATS_DESC_COUNTER(VCPU, mmio_exit_kernel),
	STATS_DESC_COUNTER(VCPU, signal_exits),
	STATS_DESC_COUNTER(VCPU, exits)
	STATS_DESC_COUNTER(VCPU, exits),
#ifdef CONFIG_ARCH_VCPU_STAT
	STATS_DESC_DFX_COUNTER(DFX, vcpu_stat)
#endif
};

const struct kvm_stats_header kvm_vcpu_stats_header = {
Loading