Commit 06f89a27 authored by chenjiajun's avatar chenjiajun Committed by liangtian
Browse files

kvm: debugfs: Export vcpu stat via debugfs

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I919BF


CVE: NA

--------------------------------------------

This patch create debugfs entry for vcpu stat.
The entry path is /sys/kernel/debug/kvm/vcpu_stat.
And vcpu_stat contains partial kvm exits items of vcpu, include:
	pid, hvc_exit_stat, wfe_exit_stat, wfi_exit_stat,
	mmio_exit_user, mmio_exit_kernel, exits

Currently, The maximum vcpu limit is 1024.

From this vcpu_stat, user can get the number of these kvm exits items
over a period of time, which is helpful to monitor the virtual machine.

Signed-off-by: default avatarchenjiajun <chenjiajun8@huawei.com>
Signed-off-by: default avatarliangtian <liangtian13@huawei.com>
parent 54465add
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
+1 −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;
+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
+19 −1
Original line number Diff line number Diff line
@@ -29,6 +29,21 @@

#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),
	{ NULL }
};
#endif

const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
	KVM_GENERIC_VM_STATS()
};
@@ -50,7 +65,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 = {
+1 −0
Original line number Diff line number Diff line
@@ -742,6 +742,7 @@ CONFIG_HAVE_KVM_NO_POLL=y
CONFIG_KVM_XFER_TO_GUEST_WORK=y
CONFIG_HAVE_KVM_PM_NOTIFIER=y
CONFIG_KVM_GENERIC_HARDWARE_ENABLING=y
CONFIG_ARCH_VCPU_STAT=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
Loading