From: Avi Kivity <avi@qumranet.com>
To: linux-kernel@vger.kernel.org, kvm-devel@lists.sourceforge.net
Subject: [PATCH 07/52] KVM: Extend stats support for VM stats
Date: Sun, 30 Dec 2007 09:09:53 +0200 [thread overview]
Message-ID: <1198998638-22713-8-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1198998638-22713-1-git-send-email-avi@qumranet.com>
This is in addition to the current virtual cpu statistics.
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
drivers/kvm/kvm.h | 14 ++++++++++++--
drivers/kvm/kvm_main.c | 26 +++++++++++++++++++++++---
drivers/kvm/x86.c | 39 ++++++++++++++++++++-------------------
3 files changed, 55 insertions(+), 24 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 5a8a9af..d3171f9 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -231,7 +231,7 @@ struct kvm_pio_request {
int rep;
};
-struct kvm_stat {
+struct kvm_vcpu_stat {
u32 pf_fixed;
u32 pf_guest;
u32 tlb_flush;
@@ -342,7 +342,7 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
wait_queue_head_t wq; \
int sigset_active; \
sigset_t sigset; \
- struct kvm_stat stat; \
+ struct kvm_vcpu_stat stat; \
KVM_VCPU_MMIO
struct kvm_mem_alias {
@@ -361,6 +361,9 @@ struct kvm_memory_slot {
int user_alloc;
};
+struct kvm_vm_stat {
+};
+
struct kvm {
struct mutex lock; /* protects everything except vcpus */
int naliases;
@@ -387,6 +390,7 @@ struct kvm {
int round_robin_prev_vcpu;
unsigned int tss_addr;
struct page *apic_access_page;
+ struct kvm_vm_stat stat;
};
static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
@@ -809,9 +813,15 @@ static inline u32 get_rdx_init_val(void)
#define TSS_REDIRECTION_SIZE (256 / 8)
#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
+enum kvm_stat_kind {
+ KVM_STAT_VM,
+ KVM_STAT_VCPU,
+};
+
struct kvm_stats_debugfs_item {
const char *name;
int offset;
+ enum kvm_stat_kind kind;
struct dentry *dentry;
};
extern struct kvm_stats_debugfs_item debugfs_entries[];
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 3aa34de..1c4e950 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1281,7 +1281,22 @@ static struct notifier_block kvm_cpu_notifier = {
.priority = 20, /* must be > scheduler priority */
};
-static u64 stat_get(void *_offset)
+static u64 vm_stat_get(void *_offset)
+{
+ unsigned offset = (long)_offset;
+ u64 total = 0;
+ struct kvm *kvm;
+
+ spin_lock(&kvm_lock);
+ list_for_each_entry(kvm, &vm_list, vm_list)
+ total += *(u32 *)((void *)kvm + offset);
+ spin_unlock(&kvm_lock);
+ return total;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(vm_stat_fops, vm_stat_get, NULL, "%llu\n");
+
+static u64 vcpu_stat_get(void *_offset)
{
unsigned offset = (long)_offset;
u64 total = 0;
@@ -1300,7 +1315,12 @@ static u64 stat_get(void *_offset)
return total;
}
-DEFINE_SIMPLE_ATTRIBUTE(stat_fops, stat_get, NULL, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(vcpu_stat_fops, vcpu_stat_get, NULL, "%llu\n");
+
+static struct file_operations *stat_fops[] = {
+ [KVM_STAT_VCPU] = &vcpu_stat_fops,
+ [KVM_STAT_VM] = &vm_stat_fops,
+};
static void kvm_init_debug(void)
{
@@ -1310,7 +1330,7 @@ static void kvm_init_debug(void)
for (p = debugfs_entries; p->name; ++p)
p->dentry = debugfs_create_file(p->name, 0444, debugfs_dir,
(void *)(long)p->offset,
- &stat_fops);
+ stat_fops[p->kind]);
}
static void kvm_exit_debug(void)
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index a46b95b..016abc3 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -42,29 +42,30 @@
#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
#define EFER_RESERVED_BITS 0xfffffffffffff2fe
-#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
+#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
+#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
struct kvm_x86_ops *kvm_x86_ops;
struct kvm_stats_debugfs_item debugfs_entries[] = {
- { "pf_fixed", STAT_OFFSET(pf_fixed) },
- { "pf_guest", STAT_OFFSET(pf_guest) },
- { "tlb_flush", STAT_OFFSET(tlb_flush) },
- { "invlpg", STAT_OFFSET(invlpg) },
- { "exits", STAT_OFFSET(exits) },
- { "io_exits", STAT_OFFSET(io_exits) },
- { "mmio_exits", STAT_OFFSET(mmio_exits) },
- { "signal_exits", STAT_OFFSET(signal_exits) },
- { "irq_window", STAT_OFFSET(irq_window_exits) },
- { "halt_exits", STAT_OFFSET(halt_exits) },
- { "halt_wakeup", STAT_OFFSET(halt_wakeup) },
- { "request_irq", STAT_OFFSET(request_irq_exits) },
- { "irq_exits", STAT_OFFSET(irq_exits) },
- { "host_state_reload", STAT_OFFSET(host_state_reload) },
- { "efer_reload", STAT_OFFSET(efer_reload) },
- { "fpu_reload", STAT_OFFSET(fpu_reload) },
- { "insn_emulation", STAT_OFFSET(insn_emulation) },
- { "insn_emulation_fail", STAT_OFFSET(insn_emulation_fail) },
+ { "pf_fixed", VCPU_STAT(pf_fixed) },
+ { "pf_guest", VCPU_STAT(pf_guest) },
+ { "tlb_flush", VCPU_STAT(tlb_flush) },
+ { "invlpg", VCPU_STAT(invlpg) },
+ { "exits", VCPU_STAT(exits) },
+ { "io_exits", VCPU_STAT(io_exits) },
+ { "mmio_exits", VCPU_STAT(mmio_exits) },
+ { "signal_exits", VCPU_STAT(signal_exits) },
+ { "irq_window", VCPU_STAT(irq_window_exits) },
+ { "halt_exits", VCPU_STAT(halt_exits) },
+ { "halt_wakeup", VCPU_STAT(halt_wakeup) },
+ { "request_irq", VCPU_STAT(request_irq_exits) },
+ { "irq_exits", VCPU_STAT(irq_exits) },
+ { "host_state_reload", VCPU_STAT(host_state_reload) },
+ { "efer_reload", VCPU_STAT(efer_reload) },
+ { "fpu_reload", VCPU_STAT(fpu_reload) },
+ { "insn_emulation", VCPU_STAT(insn_emulation) },
+ { "insn_emulation_fail", VCPU_STAT(insn_emulation_fail) },
{ NULL }
};
--
1.5.3.7
next prev parent reply other threads:[~2007-12-30 7:13 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-30 7:09 [PATCH 00/52] KVM patch queue review for 2.6.25 merge window (part III) Avi Kivity
2007-12-30 7:09 ` [PATCH 01/52] KVM: Remove ptr comparisons to 0 Avi Kivity
2007-12-30 7:09 ` [PATCH 02/52] KVM: Remove __init attributes for kvm_init_debug and kvm_init_msr_list Avi Kivity
2007-12-30 7:09 ` [PATCH 03/52] KVM: Portability: Add two hooks to handle kvm_create and destroy vm Avi Kivity
2007-12-30 7:09 ` [PATCH 04/52] KVM: Replace 'light_exits' stat with 'host_state_reload' Avi Kivity
2007-12-30 7:09 ` [PATCH 05/52] KVM: Add fpu_reload counter Avi Kivity
2007-12-30 7:09 ` [PATCH 06/52] KVM: Add instruction emulation statistics Avi Kivity
2007-12-30 7:09 ` Avi Kivity [this message]
2007-12-30 7:09 ` [PATCH 08/52] KVM: MMU: Add some mmu statistics Avi Kivity
2007-12-30 7:09 ` [PATCH 09/52] KVM: Make unloading of FPU state when putting vcpu arch-independent Avi Kivity
2007-12-30 7:09 ` [PATCH 10/52] KVM: Portability: Move kvm_vcpu_ioctl_get_dirty_log to arch-specific file Avi Kivity
2007-12-30 7:09 ` [PATCH 11/52] KVM: Portability: MMU initialization and teardown split Avi Kivity
2007-12-30 7:09 ` [PATCH 12/52] KVM: Portability: Move some macro definitions from kvm.h to x86.h Avi Kivity
2007-12-30 7:09 ` [PATCH 13/52] KVM: Portability: Move struct kvm_x86_ops definition " Avi Kivity
2007-12-30 7:10 ` [PATCH 14/52] KVM: Portability: Move vcpu regs enumeration " Avi Kivity
2007-12-30 7:10 ` [PATCH 15/52] KVM: Move some static inline functions out from kvm.h into x86.h Avi Kivity
2007-12-30 7:10 ` [PATCH 16/52] KVM: Portability: Move some function declarations to x86.h Avi Kivity
2007-12-30 7:10 ` [PATCH 17/52] KVM: VMX: Force seg.base == (seg.sel << 4) in real mode Avi Kivity
2007-12-30 7:10 ` [PATCH 18/52] KVM: MMU: Change guest pte access to kvm_{read,write}_guest() Avi Kivity
2007-12-30 7:10 ` [PATCH 19/52] KVM: Simplify kvm_clear_guest_page() Avi Kivity
2007-12-30 7:10 ` [PATCH 20/52] KVM: Add missing #include <asm/pgtable.h> Avi Kivity
2008-01-03 18:14 ` Adrian Bunk
2008-01-06 9:09 ` [kvm-devel] " Avi Kivity
2007-12-30 7:10 ` [PATCH 21/52] KVM: MMU: Remove unused variable Avi Kivity
2007-12-30 7:10 ` [PATCH 22/52] KVM: Remove unused "rmap_overflow" variable Avi Kivity
2007-12-30 7:10 ` [PATCH 23/52] KVM: Correct consistent typo: "destory" -> "destroy" Avi Kivity
2007-12-30 7:10 ` [PATCH 24/52] KVM: Move misplaced comment Avi Kivity
2007-12-30 7:10 ` [PATCH 25/52] KVM: Portability: Move kvm_memory_alias to asm/kvm.h Avi Kivity
2007-12-30 7:10 ` [PATCH 26/52] KVM: Portability: Move x86 pic strutctures Avi Kivity
2007-12-30 7:10 ` [PATCH 27/52] KVM: Portability: Move kvm_regs to <asm/kvm.h> Avi Kivity
2007-12-30 7:10 ` [PATCH 28/52] KVM: Portability: Move structure lapic_state " Avi Kivity
2007-12-30 7:10 ` [PATCH 29/52] KVM: Portability: Move kvm_segment & kvm_dtable structure " Avi Kivity
2007-12-30 7:10 ` [PATCH 30/52] KVM: Portability: Move kvm_sregs and msr structures " Avi Kivity
2007-12-30 7:10 ` [PATCH 31/52] KVM: Portability: Move cpuid " Avi Kivity
2007-12-30 7:10 ` [PATCH 32/52] KVM: Export include/asm-x86/kvm.h Avi Kivity
2007-12-30 7:10 ` [PATCH 33/52] KVM: MMU: Fix potential memory leak with smp real-mode Avi Kivity
2007-12-30 7:10 ` [PATCH 34/52] KVM: MMU: Selectively set PageDirty when releasing guest memory Avi Kivity
2007-12-30 7:10 ` [PATCH 35/52] KVM: x86 emulator: retire ->write_std() Avi Kivity
2007-12-30 7:10 ` [PATCH 36/52] KVM: x86 emulator: prefetch up to 15 bytes of the instruction executed Avi Kivity
2007-12-30 7:10 ` [PATCH 37/52] KVM: Recalculate mmu pages needed for every memory region change Avi Kivity
2007-12-30 7:10 ` [PATCH 38/52] KVM: Portability: Split kvm_set_memory_region() to have an arch callout Avi Kivity
2007-12-30 7:10 ` [PATCH 39/52] KVM: Split vcpu creation to avoid vcpu_load() before preemption setup Avi Kivity
2007-12-30 7:10 ` [PATCH 40/52] KVM: MMU: Implement guest page fault bypass for nonpae Avi Kivity
2007-12-30 7:10 ` [PATCH 41/52] KVM: Add statistic for remote tlb flushes Avi Kivity
2007-12-30 7:10 ` [PATCH 42/52] KVM: MMU: Avoid unnecessary remote tlb flushes when guest updates a pte Avi Kivity
2007-12-30 7:10 ` [PATCH 43/52] KVM: Don't bother the mmu if cr3 load doesn't change cr3 Avi Kivity
2007-12-30 7:10 ` [PATCH 44/52] KVM: MMU: Code cleanup Avi Kivity
2007-12-30 7:10 ` [PATCH 45/52] KVM: MMU: Introduce and use gpte_to_gfn() Avi Kivity
2007-12-30 7:10 ` [PATCH 46/52] KVM: MMU: Move pse36 handling to the guest walker Avi Kivity
2007-12-30 7:10 ` [PATCH 47/52] KVM: MMU: Remove extra gaddr parameter from set_pte_common() Avi Kivity
2007-12-30 7:10 ` [PATCH 48/52] KVM: MMU: Remove set_pde() Avi Kivity
2007-12-30 7:10 ` [PATCH 49/52] KVM: MMU: Merge set_pte() and set_pte_common() Avi Kivity
2007-12-30 7:10 ` [PATCH 50/52] KVM: MMU: Adjust page_header_update_slot() to accept a gfn instead of a gpa Avi Kivity
2007-12-30 7:10 ` [PATCH 51/52] KVM: MMU: Introduce gfn_to_gpa() Avi Kivity
2007-12-30 7:10 ` [PATCH 52/52] KVM: MMU: Simplify nonpaging_map() Avi Kivity
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=1198998638-22713-8-git-send-email-avi@qumranet.com \
--to=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®