KVM: stats: Support binary stats retrieval for a VCPU
Add a VCPU ioctl to get a statistics file descriptor by which a read functionality is provided for userspace to read out VCPU stats header, descriptors and data. Define VCPU statistics descriptors and header for all architectures. Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Ricardo Koller <ricarkol@google.com> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> #arm64 Signed-off-by: Jing Zhang <jingzhangos@google.com> Message-Id: <20210618222709.1858088-5-jingzhangos@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
fcfe1baedd
commit
ce55c04945
8 changed files with 359 additions and 2 deletions
|
|
@ -305,7 +305,6 @@ struct kvm_vcpu {
|
|||
struct pid __rcu *pid;
|
||||
int sigset_active;
|
||||
sigset_t sigset;
|
||||
struct kvm_vcpu_stat stat;
|
||||
unsigned int halt_poll_ns;
|
||||
bool valid_wakeup;
|
||||
|
||||
|
|
@ -342,6 +341,8 @@ struct kvm_vcpu {
|
|||
bool preempted;
|
||||
bool ready;
|
||||
struct kvm_vcpu_arch arch;
|
||||
struct kvm_vcpu_stat stat;
|
||||
char stats_id[KVM_STATS_NAME_SIZE];
|
||||
struct kvm_dirty_ring dirty_ring;
|
||||
};
|
||||
|
||||
|
|
@ -1358,6 +1359,14 @@ struct _kvm_stats_desc {
|
|||
#define KVM_GENERIC_VM_STATS() \
|
||||
STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush)
|
||||
|
||||
#define KVM_GENERIC_VCPU_STATS() \
|
||||
STATS_DESC_COUNTER(VCPU_GENERIC, halt_successful_poll), \
|
||||
STATS_DESC_COUNTER(VCPU_GENERIC, halt_attempted_poll), \
|
||||
STATS_DESC_COUNTER(VCPU_GENERIC, halt_poll_invalid), \
|
||||
STATS_DESC_COUNTER(VCPU_GENERIC, halt_wakeup), \
|
||||
STATS_DESC_TIME_NSEC(VCPU_GENERIC, halt_poll_success_ns), \
|
||||
STATS_DESC_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_ns)
|
||||
|
||||
extern struct kvm_stats_debugfs_item debugfs_entries[];
|
||||
extern struct dentry *kvm_debugfs_dir;
|
||||
ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
|
||||
|
|
@ -1366,6 +1375,8 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
|
|||
char __user *user_buffer, size_t size, loff_t *offset);
|
||||
extern const struct kvm_stats_header kvm_vm_stats_header;
|
||||
extern const struct _kvm_stats_desc kvm_vm_stats_desc[];
|
||||
extern const struct kvm_stats_header kvm_vcpu_stats_header;
|
||||
extern const struct _kvm_stats_desc kvm_vcpu_stats_desc[];
|
||||
|
||||
#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
|
||||
static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue