debugfs directory for each VM
PATCH 1/1 debugfs directory for each VM
Hi all,
This patch allows a VM to have own directory on debugfs, that contains statics only for the VM. Each directory is identified by the pid of the VM (ie qemu).
I tried this patch under several host kernel versions, .22, .23, and .24, and confirmed things work out well.
Thanks,
ozaki-r
--
arch/x86/kvm/x86.c | 5 ++- include/linux/kvm_host.h | 8 ++++ virt/kvm/kvm_main.c | 81 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 82 insertions(+), 12 deletions(-)
arch/x86/kvm/x86.c +0 -0
@@ -53,8 +53,8 @@ static u64 __read_mostly efer_reserved_bits =
0xfffffffffffffafeULL;
static u64 __read_mostly efer_reserved_bits = 0xfffffffffffffffeULL; #endif
-#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 +#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM, NULL +#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, NULL
static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
struct kvm_cpuid_entry2 __user *entries);
@@ -93,6 +93,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
{ NULL }
};
+size_t debugfs_entries_size = sizeof(debugfs_entries)/sizeof(debugfs_entries[0]);
unsigned long segment_base(u16 selector)
{
include/linux/kvm_host.h +8 -0
@@ -43,6 +43,11 @@struct kvm_vcpu ;extern struct kmem_cache *kvm_vcpu_cache; +struct kvm_debugfs { +struct dentry *dentry; +struct kvm_stats_debugfs_item *debugfs_entries; +}; +struct kvm_guest_debug {int enabled;unsigned long bp[4 ];
@@ -127,6 +132,7 @@ struct kvm {struct kvm_io_bus pio_bus;struct kvm_vm_stat stat;struct kvm_arch arch; +struct kvm_debugfs debugfs; };/* The guest did something we don't support. */
@@ -304,7 +310,9 @@ struct kvm_stats_debugfs_item {int offset;enum kvm_stat_kind kind;struct dentry *dentry; + struct kvm *kvm; };extern struct kvm_stats_debugfs_item debugfs_entries[]; +extern size_t debugfs_entries_size;#endif
virt/kvm/kvm_main.c +42 -10
106 lines not on this page · raw message
kvm_stats_debugfs_item)*debugfs_entries_size, GFP_KERNEL);
+ if (p == NULL) {
+ debugfs_remove(dir);
+ return;
+ }
+ memcpy(p, debugfs_entries, sizeof(struct
kvm_stats_debugfs_item)*debugfs_entries_size);
+
+ kvm_debugfs->dentry = dir;
+ kvm_debugfs->debugfs_entries = p;
+ for (; p->name; ++p) {
+ p->kvm = kvm;
+ p->dentry = debugfs_create_file(p->name, 0444, dir,
+ (void *)p,
+ stat_fops[p->kind]);
+ }
+ return;
+}
+
+static void kvm_debugfs_destroy(struct kvm *kvm)
+{
+ struct kvm_stats_debugfs_item *p;
+ struct kvm_debugfs *debugfs = &kvm->debugfs;
+
+ p = debugfs->debugfs_entries;
+ for (; p->name; ++p)
+ debugfs_remove(p->dentry);
+ debugfs_remove(debugfs->dentry);
+ kfree(debugfs->debugfs_entries);
+}
+
static int kvm_suspend(struct sys_device *dev, pm_message_t state) {
hardware_disable(NULL);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 9 lines · Ryota OZAKI
Hi all,
This patch allows a VM to have own directory on debugfs, that contains statics only for the VM. Each directory is identified by the pid of the VM (ie qemu).
I tried this patch under several host kernel versions, .22, .23, and .24, and confirmed things work out well.
Nice patch; it's certainly useful to improve per-vm trace capabilities.
It would be nice to keep the summary, since that allows running kvm_stat with no arguments.
On the other hand, the kvmtrace patchset recently posted adds much more detailed data; we should probably concentrate on that as a means of improving performance tracing.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Hi Avi,
2008/3/17, Avi Kivity <[email protected]>:
Quoted 12 lines
Quoted 9 lines · Ryota OZAKI
Hi all,
This patch allows a VM to have own directory on debugfs, that contains statics only for the VM. Each directory is identified by the pid of the VM (ie qemu).
I tried this patch under several host kernel versions, .22, .23, and .24, and confirmed things work out well.
Quoted 4 lines
Nice patch; it's certainly useful to improve per-vm trace capabilities.
It would be nice to keep the summary, since that allows running
kvm_statwith no arguments.
My patch keeps the summary. But it actually breaks a kvm_stat's assumption so kvm_stat doesn't work under kvm with my patch. I wrote a patch to fix this problem. See the following patch. (i'm not familiar with python, sorry.)
Quoted 3 lines
On the other hand, the kvmtrace patchset recently posted adds much more detailed data; we should probably concentrate on that as a means of improving performance tracing.
The patchset is useful for me, too. I will concentrate that as well.
Thanks,
ozaki-r
Quoted 2 lines
--
error compilingcommittee.c: too many arguments to function
--
kvm_stat | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-)
kvm_stat +18 -7
@@ -4,11 +4,15 @@ import curses import sys, os, time, optparse class Stats: - def __init__(self): - self.base = '/sys/kernel/debug/kvm' + def __init__(self, pid = None): + if pid: + self.base = '/sys/kernel/debug/kvm/' + pid + else: + self.base = '/sys/kernel/debug/kvm' self.values = {} for key in os.listdir(self.base): - self.values[key] = None + if not os.path.isdir(self.base + '/' + key): + self.values[key] = None def get(self): for key, oldval in self.values.iteritems(): newval = int(file(self.base + '/' + key).read())
@@ -26,7 +30,6 @@ if not os.access('/sys/kernel/debug/kvm', os.F_OK): print "and ensure the kvm modules are loaded" sys.exit(1) -stats = Stats() label_width = 20 number_width = 10
@@ -73,14 +76,22 @@ def batch(stats): values = s[key] print '%-22s%10d%10d' % (key, values[0], values[1]) -options = optparse.OptionParser() -options.add_option('-1', '--once', '--batch', +usage = "usage: %prog [options] [<pid>]" +parser = optparse.OptionParser(usage) +parser.add_option('-1', '--once', '--batch', action = 'store_true', default = False, dest = 'once', help = 'run in batch mode for one second', ) -(options, args) = options.parse_args(sys.argv) +(options, args) = parser.parse_args(sys.argv) + +if len(args) == 1: + stats = Stats() +elif len(args) == 2: + stats = Stats(args[1]) +else: + parser.error("too many arguments.") if not options.once: import curses.wrapper
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/