From 1cd5fdd0e99e8dee924f9696e128eb1a2e288f6e Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 10 Jan 2007 23:15:38 -0800 Subject: [PATCH] --- yaml --- r: 45478 b: refs/heads/master c: 07031e14c1127fc7e1a5b98dfcc59f434e025104 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/kvm/svm.c | 8 ++++++++ trunk/drivers/kvm/vmx.c | 7 +++++++ trunk/include/linux/profile.h | 1 + trunk/kernel/profile.c | 14 ++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 7c70678a40ac..75b7768c8f62 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e3881a6816b45668df60a426e5c3431ece1539a7 +refs/heads/master: 07031e14c1127fc7e1a5b98dfcc59f434e025104 diff --git a/trunk/drivers/kvm/svm.c b/trunk/drivers/kvm/svm.c index ccc06b1b91b5..714f6a7841cd 100644 --- a/trunk/drivers/kvm/svm.c +++ b/trunk/drivers/kvm/svm.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "kvm_svm.h" @@ -1558,6 +1559,13 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) reload_tss(vcpu); + /* + * Profile KVM exit RIPs: + */ + if (unlikely(prof_on == KVM_PROFILING)) + profile_hit(KVM_PROFILING, + (void *)(unsigned long)vcpu->svm->vmcb->save.rip); + stgi(); kvm_reput_irq(vcpu); diff --git a/trunk/drivers/kvm/vmx.c b/trunk/drivers/kvm/vmx.c index d4701cb4c654..ce219e3f557f 100644 --- a/trunk/drivers/kvm/vmx.c +++ b/trunk/drivers/kvm/vmx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -1859,6 +1860,12 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); #endif + /* + * Profile KVM exit RIPs: + */ + if (unlikely(prof_on == KVM_PROFILING)) + profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP)); + kvm_run->exit_type = 0; if (fail) { kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY; diff --git a/trunk/include/linux/profile.h b/trunk/include/linux/profile.h index 5670b340c4ef..eec48f5f9348 100644 --- a/trunk/include/linux/profile.h +++ b/trunk/include/linux/profile.h @@ -15,6 +15,7 @@ extern int prof_on __read_mostly; #define CPU_PROFILING 1 #define SCHED_PROFILING 2 #define SLEEP_PROFILING 3 +#define KVM_PROFILING 4 struct proc_dir_entry; struct pt_regs; diff --git a/trunk/kernel/profile.c b/trunk/kernel/profile.c index 11550b2290b6..a6574a18514e 100644 --- a/trunk/kernel/profile.c +++ b/trunk/kernel/profile.c @@ -40,7 +40,10 @@ int (*timer_hook)(struct pt_regs *) __read_mostly; static atomic_t *prof_buffer; static unsigned long prof_len, prof_shift; + int prof_on __read_mostly; +EXPORT_SYMBOL_GPL(prof_on); + static cpumask_t prof_cpu_mask = CPU_MASK_ALL; #ifdef CONFIG_SMP static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); @@ -52,6 +55,7 @@ static int __init profile_setup(char * str) { static char __initdata schedstr[] = "schedule"; static char __initdata sleepstr[] = "sleep"; + static char __initdata kvmstr[] = "kvm"; int par; if (!strncmp(str, sleepstr, strlen(sleepstr))) { @@ -72,6 +76,15 @@ static int __init profile_setup(char * str) printk(KERN_INFO "kernel schedule profiling enabled (shift: %ld)\n", prof_shift); + } else if (!strncmp(str, kvmstr, strlen(kvmstr))) { + prof_on = KVM_PROFILING; + if (str[strlen(kvmstr)] == ',') + str += strlen(kvmstr) + 1; + if (get_option(&str, &par)) + prof_shift = par; + printk(KERN_INFO + "kernel KVM profiling enabled (shift: %ld)\n", + prof_shift); } else if (get_option(&str, &par)) { prof_shift = par; prof_on = CPU_PROFILING; @@ -318,6 +331,7 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits) local_irq_restore(flags); put_cpu(); } +EXPORT_SYMBOL_GPL(profile_hits); static int __devinit profile_cpu_callback(struct notifier_block *info, unsigned long action, void *__cpu)