On Mon, 15 Jun 2009, Marcelo Tosatti wrote: > This allows use of the powerful ftrace infrastructure. > > See Documentation/trace/ for usage information. > > Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> > > Index: kvm/arch/x86/kvm/svm.c > =================================================================== > --- kvm.orig/arch/x86/kvm/svm.c > +++ kvm/arch/x86/kvm/svm.c > @@ -29,6 +29,9 @@ > #include <asm/desc.h> > > #include <asm/virtext.h> > +#include "svm-trace.h" > +#define CREATE_TRACE_POINTS > +#include <trace/events/kvm/x86-arch.h> > > #define __ex(x) __kvm_handle_fault_on_reboot(x) > > Index: kvm/arch/x86/kvm/vmx.c > =================================================================== > --- kvm.orig/arch/x86/kvm/vmx.c > +++ kvm/arch/x86/kvm/vmx.c > @@ -34,6 +34,10 @@ > #include <asm/virtext.h> > #include <asm/mce.h> > > +#include "vmx-trace.h" > +#define CREATE_TRACE_POINTS > +#include <trace/events/kvm/x86-arch.h> > + > #define __ex(x) __kvm_handle_fault_on_reboot(x) > > MODULE_AUTHOR("Qumranet"); > Index: kvm/arch/x86/kvm/x86.c > =================================================================== > --- kvm.orig/arch/x86/kvm/x86.c > +++ kvm/arch/x86/kvm/x86.c > @@ -37,6 +37,8 @@ > #include <linux/iommu.h> > #include <linux/intel-iommu.h> > #include <linux/cpufreq.h> > +#define CREATE_TRACE_POINTS > +#include <trace/events/kvm/x86.h> > > #include <asm/uaccess.h> > #include <asm/msr.h> > @@ -347,9 +349,6 @@ EXPORT_SYMBOL_GPL(kvm_set_cr0); > Index: kvm/include/trace/events/kvm/x86-arch.h > =================================================================== > --- /dev/null > +++ kvm/include/trace/events/kvm/x86-arch.h One suggestion. Instead of putting in arch specific trace points into generic code, you can put these into arch/x86/kvm/trace.h ? Then you can in the Makefile add: CFLAGS_x86.o := -I. CFLAGS_svm.o := -I. CFLAGS_vmx.o := -I. Or better yet, have a single file called trace.c: in the Makefile: CFLAGS_trace.o := -I. obj-$(EVENT_TRACING) += trace.o in trace.c: #define CREATE_TRACE_POINTS #include "trace.h" #include "trace-arch.h" Then have the kvm/x86.h moved to trace.h and the kvm/arch-x86.h move to trace-arch.h Just change the "TRACE_INCLUDE_FILE" to include the proper name. -- Steve > @@ -0,0 +1,128 @@ > +#if !defined(_TRACE_KVM_ARCH_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_KVM_ARCH_H > + > +#include <linux/tracepoint.h> > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM kvm > +#define TRACE_INCLUDE_FILE kvm/x86-arch > + > +/* > + * Tracepoint for kvm guest exit: > + */ > +TRACE_EVENT(kvm_exit, > + TP_PROTO(unsigned int exit_reason, unsigned long guest_rip), > + TP_ARGS(exit_reason, guest_rip), > + > + TP_STRUCT__entry( > + __field( unsigned int, exit_reason ) > + __field( unsigned long, guest_rip ) > + ), > + > + TP_fast_assign( > + __entry->exit_reason = exit_reason; > + __entry->guest_rip = guest_rip; > + ), > + > + TP_printk("reason %s rip 0x%lx", > + __print_symbolic(__entry->exit_reason, exit_reasons), > + __entry->guest_rip) > +); > + > +/* > + * Tracepoint for kvm interrupt injection: > + */ > +TRACE_EVENT(kvm_inj_virq, > + TP_PROTO(unsigned int irq), > + TP_ARGS(irq), > + > + TP_STRUCT__entry( > + __field( unsigned int, irq ) > + ), > + > + TP_fast_assign( > + __entry->irq = irq; > + ), > + > + TP_printk("irq %u", __entry->irq) > +); > + > +/* > + * Tracepoint for page fault. > + */ > +TRACE_EVENT(kvm_page_fault, > + TP_PROTO(unsigned long fault_address, unsigned int error_code), > + TP_ARGS(fault_address, error_code), > + > + TP_STRUCT__entry( > + __field( unsigned long, fault_address ) > + __field( unsigned int, error_code ) > + ), > + > + TP_fast_assign( > + __entry->fault_address = fault_address; > + __entry->error_code = error_code; > + ), > + > + TP_printk("address %lx error_code %x", > + __entry->fault_address, __entry->error_code) > +); > + > +/* > + * Tracepoint for guest MSR access. > + */ > +TRACE_EVENT(kvm_msr, > + TP_PROTO(unsigned int rw, unsigned int ecx, unsigned long data), > + TP_ARGS(rw, ecx, data), > + > + TP_STRUCT__entry( > + __field( unsigned int, rw ) > + __field( unsigned int, ecx ) > + __field( unsigned long, data ) > + ), > + > + TP_fast_assign( > + __entry->rw = rw; > + __entry->ecx = ecx; > + __entry->data = data; > + ), > + > + TP_printk("msr_%s %x = 0x%lx", > + __entry->rw ? "write" : "read", > + __entry->ecx, __entry->data) > +); > + > +#define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data) > +#define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data) > + > +/* > + * Tracepoint for guest CR access. > + */ > +TRACE_EVENT(kvm_cr, > + TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), > + TP_ARGS(rw, cr, val), > + > + TP_STRUCT__entry( > + __field( unsigned int, rw ) > + __field( unsigned int, cr ) > + __field( unsigned long, val ) > + ), > + > + TP_fast_assign( > + __entry->rw = rw; > + __entry->cr = cr; > + __entry->val = val; > + ), > + > + TP_printk("cr_%s %x = 0x%lx", > + __entry->rw ? "write" : "read", > + __entry->cr, __entry->val) > +); > + > +#define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) > +#define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) > + > +#endif /* _TRACE_KVM_ARCH_H */ > + > +/* This part must be outside protection */ > +#include <trace/define_trace.h> > Index: kvm/include/trace/events/kvm/x86.h > =================================================================== > --- /dev/null > +++ kvm/include/trace/events/kvm/x86.h > @@ -0,0 +1,143 @@ > +#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_KVM_H > + > +#include <linux/tracepoint.h> > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM kvm > +#define TRACE_INCLUDE_FILE kvm/x86 > + > +/* > + * Tracepoint for guest mode entry. > + */ > +TRACE_EVENT(kvm_entry, > + TP_PROTO(unsigned int vcpu_id), > + TP_ARGS(vcpu_id), > + > + TP_STRUCT__entry( > + __field( unsigned int, vcpu_id ) > + ), > + > + TP_fast_assign( > + __entry->vcpu_id = vcpu_id; > + ), > + > + TP_printk("vcpu %u\n", __entry->vcpu_id) > +); > + > +/* > + * Tracepoint for hypercall. > + */ > +TRACE_EVENT(kvm_hypercall, > + TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1, > + unsigned long a2, unsigned long a3), > + TP_ARGS(nr, a0, a1, a2, a3), > + > + TP_STRUCT__entry( > + __field( unsigned long, nr ) > + __field( unsigned long, a0 ) > + __field( unsigned long, a1 ) > + __field( unsigned long, a2 ) > + __field( unsigned long, a3 ) > + ), > + > + TP_fast_assign( > + __entry->nr = nr; > + __entry->a0 = a0; > + __entry->a1 = a1; > + __entry->a2 = a2; > + __entry->a3 = a3; > + ), > + > + TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx", > + __entry->nr, __entry->a0, __entry->a1, __entry->a2, > + __entry->a3) > +); > + > +/* > + * Tracepoint for PIO. > + */ > +TRACE_EVENT(kvm_pio, > + TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, > + unsigned int count), > + TP_ARGS(rw, port, size, count), > + > + TP_STRUCT__entry( > + __field( unsigned int, rw ) > + __field( unsigned int, port ) > + __field( unsigned int, size ) > + __field( unsigned int, count ) > + ), > + > + TP_fast_assign( > + __entry->rw = rw; > + __entry->port = port; > + __entry->size = size; > + __entry->count = count; > + ), > + > + TP_printk("pio_%s at 0x%x size %d count %d", > + __entry->rw ? "write" : "read", > + __entry->port, __entry->size, __entry->count) > +); > + > +/* > + * Tracepoint for cpuid. > + */ > +TRACE_EVENT(kvm_cpuid, > + TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx, > + unsigned long rcx, unsigned long rdx), > + TP_ARGS(function, rax, rbx, rcx, rdx), > + > + TP_STRUCT__entry( > + __field( unsigned int, function ) > + __field( unsigned long, rax ) > + __field( unsigned long, rbx ) > + __field( unsigned long, rcx ) > + __field( unsigned long, rdx ) > + ), > + > + TP_fast_assign( > + __entry->function = function; > + __entry->rax = rax; > + __entry->rbx = rbx; > + __entry->rcx = rcx; > + __entry->rdx = rdx; > + ), > + > + TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx", > + __entry->function, __entry->rax, > + __entry->rbx, __entry->rcx, __entry->rdx) > +); > + > +/* > + * Tracepoint for apic access. > + */ > +TRACE_EVENT(kvm_apic, > + TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), > + TP_ARGS(rw, reg, val), > + > + TP_STRUCT__entry( > + __field( unsigned int, rw ) > + __field( unsigned int, reg ) > + __field( unsigned int, val ) > + ), > + > + TP_fast_assign( > + __entry->rw = rw; > + __entry->reg = reg; > + __entry->val = val; > + ), > + > + TP_printk("apic_%s 0x%x = 0x%x", > + __entry->rw ? "write" : "read", > + __entry->reg, __entry->val) > +); > + > +#define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val) > +#define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val) > + > +#endif /* _TRACE_KVM_H */ > + > +/* This part must be outside protection */ > +#include <trace/define_trace.h> > Index: kvm/include/trace/events/kvm/kvm.h > =================================================================== > --- /dev/null > +++ kvm/include/trace/events/kvm/kvm.h > @@ -0,0 +1,55 @@ > +#if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_KVM_MAIN_H > + > +#include <linux/tracepoint.h> > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM kvm > +#define TRACE_INCLUDE_FILE kvm/kvm > + > +TRACE_EVENT(kvm_set_irq, > + TP_PROTO(unsigned int gsi), > + TP_ARGS(gsi), > + > + TP_STRUCT__entry( > + __field( unsigned int, gsi ) > + ), > + > + TP_fast_assign( > + __entry->gsi = gsi; > + ), > + > + TP_printk("gsi %u", __entry->gsi) > +); > + > + > +#define kvm_irqchips \ > + {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \ > + {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \ > + {KVM_IRQCHIP_IOAPIC, "IOAPIC"} > + > +TRACE_EVENT(kvm_ack_irq, > + TP_PROTO(unsigned int irqchip, unsigned int pin), > + TP_ARGS(irqchip, pin), > + > + TP_STRUCT__entry( > + __field( unsigned int, irqchip ) > + __field( unsigned int, pin ) > + ), > + > + TP_fast_assign( > + __entry->irqchip = irqchip; > + __entry->pin = pin; > + ), > + > + TP_printk("irqchip %s pin %u", > + __print_symbolic(__entry->irqchip, kvm_irqchips), > + __entry->pin) > +); > + > + > + > +#endif /* _TRACE_KVM_MAIN_H */ > + > +/* This part must be outside protection */ > +#include <trace/define_trace.h> > Index: kvm/virt/kvm/irq_comm.c > =================================================================== > --- kvm.orig/virt/kvm/irq_comm.c > +++ kvm/virt/kvm/irq_comm.c > @@ -20,6 +20,7 @@ > */ > > #include <linux/kvm_host.h> > +#include <trace/events/kvm/kvm.h> > > #include <asm/msidef.h> > #ifdef CONFIG_IA64 > @@ -125,6 +126,8 @@ int kvm_set_irq(struct kvm *kvm, int irq > unsigned long *irq_state, sig_level; > int ret = -1; > > + trace_kvm_set_irq(irq); > + > WARN_ON(!mutex_is_locked(&kvm->irq_lock)); > > if (irq < KVM_IOAPIC_NUM_PINS) { > @@ -161,6 +164,8 @@ void kvm_notify_acked_irq(struct kvm *kv > struct hlist_node *n; > unsigned gsi = pin; > > + trace_kvm_ack_irq(irqchip, pin); > + > list_for_each_entry(e, &kvm->irq_routing, link) > if (e->irqchip.irqchip == irqchip && > e->irqchip.pin == pin) { > Index: kvm/virt/kvm/kvm_main.c > =================================================================== > --- kvm.orig/virt/kvm/kvm_main.c > +++ kvm/virt/kvm/kvm_main.c > @@ -59,6 +59,9 @@ > #include "irq.h" > #endif > > +#define CREATE_TRACE_POINTS > +#include <trace/events/kvm/kvm.h> > + > MODULE_AUTHOR("Qumranet"); > MODULE_LICENSE("GPL"); > > @@ -2715,6 +2718,7 @@ EXPORT_SYMBOL_GPL(kvm_init); > void kvm_exit(void) > { > kvm_trace_cleanup(); > + tracepoint_synchronize_unregister(); > misc_deregister(&kvm_dev); > kmem_cache_destroy(kvm_vcpu_cache); > sysdev_unregister(&kvm_sysdev); > > -- > > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html