aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-11-18 09:24:12 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:04 -0500
commitba1389b7a04de07e6231693b7ebb34f5b5d1a3e6 (patch)
tree536139f6e1d3a918b13a9c44f2144c52366a55bb /drivers/kvm/kvm_main.c
parentf2b5756bb3fbdca912c4890e444c18650389d8ae (diff)
KVM: Extend stats support for VM stats
This is in addition to the current virtual cpu statistics. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index bde3cf741892..b0b6ff2a8cbe 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1281,7 +1281,22 @@ static struct notifier_block kvm_cpu_notifier = {
1281 .priority = 20, /* must be > scheduler priority */ 1281 .priority = 20, /* must be > scheduler priority */
1282}; 1282};
1283 1283
1284static u64 stat_get(void *_offset) 1284static u64 vm_stat_get(void *_offset)
1285{
1286 unsigned offset = (long)_offset;
1287 u64 total = 0;
1288 struct kvm *kvm;
1289
1290 spin_lock(&kvm_lock);
1291 list_for_each_entry(kvm, &vm_list, vm_list)
1292 total += *(u32 *)((void *)kvm + offset);
1293 spin_unlock(&kvm_lock);
1294 return total;
1295}
1296
1297DEFINE_SIMPLE_ATTRIBUTE(vm_stat_fops, vm_stat_get, NULL, "%llu\n");
1298
1299static u64 vcpu_stat_get(void *_offset)
1285{ 1300{
1286 unsigned offset = (long)_offset; 1301 unsigned offset = (long)_offset;
1287 u64 total = 0; 1302 u64 total = 0;
@@ -1300,7 +1315,12 @@ static u64 stat_get(void *_offset)
1300 return total; 1315 return total;
1301} 1316}
1302 1317
1303DEFINE_SIMPLE_ATTRIBUTE(stat_fops, stat_get, NULL, "%llu\n"); 1318DEFINE_SIMPLE_ATTRIBUTE(vcpu_stat_fops, vcpu_stat_get, NULL, "%llu\n");
1319
1320static struct file_operations *stat_fops[] = {
1321 [KVM_STAT_VCPU] = &vcpu_stat_fops,
1322 [KVM_STAT_VM] = &vm_stat_fops,
1323};
1304 1324
1305static void kvm_init_debug(void) 1325static void kvm_init_debug(void)
1306{ 1326{
@@ -1310,7 +1330,7 @@ static void kvm_init_debug(void)
1310 for (p = debugfs_entries; p->name; ++p) 1330 for (p = debugfs_entries; p->name; ++p)
1311 p->dentry = debugfs_create_file(p->name, 0444, debugfs_dir, 1331 p->dentry = debugfs_create_file(p->name, 0444, debugfs_dir,
1312 (void *)(long)p->offset, 1332 (void *)(long)p->offset,
1313 &stat_fops); 1333 stat_fops[p->kind]);
1314} 1334}
1315 1335
1316static void kvm_exit_debug(void) 1336static void kvm_exit_debug(void)