replace kvmtrace with event traces
cover replace kvmtrace with event traces
PATCH 1/2 KVM: convert custom marker based tracing to event traces
This allows use of the powerful ftrace infrastructure.
See Documentation/trace/ for usage information.
arch/x86/kvm/lapic.c +4 -3
@@ -26,6 +26,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/math64.h> +#include <trace/events/kvm/x86.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/page.h>
@@ -515,8 +516,6 @@ static u32 __apic_read(struct kvm_lapic {u32 val =0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); -if (offset >=LAPIC_MMIO_LENGTH )return 0 ;
@@ -562,6 +561,8 @@ static void apic_mmio_read(struct kvm_io } result =__apic_read (apic, offset & ~0xf ); +trace_kvm_apic_read (offset, result); +switch (len) {case 1 :case 2 :
@@ -657,7 +658,7 @@ static void apic_mmio_write(struct kvm_i offset &=0xff0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); +trace_kvm_apic_write (offset, val);switch (offset) {case APIC_ID :/* Local APIC ID */
arch/x86/kvm/svm-trace.h new file +51 -0
51 lines not on this page · raw message
arch/x86/kvm/svm.c +8 -22
@@ -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)
@@ -1113,7 +1116,6 @@ static unsigned long svm_get_dr(struct k val =0 ; } -KVMTRACE_2D (DR_READ , vcpu, (u32 )dr, (u32 )val, handler);return val; }
@@ -1122,8 +1124,6 @@ static void svm_set_dr(struct kvm_vcpu * {struct vcpu_svm *svm =to_svm (vcpu); -KVMTRACE_2D (DR_WRITE , vcpu, (u32 )dr, (u32 )value, handler); - *exception =0 ;switch (dr) {
@@ -1171,14 +1171,7 @@ static int pf_interception(struct vcpu_s fault_address = svm->vmcb->control.exit_info_2; error_code = svm->vmcb->control.exit_info_1; -if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); -else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);/* * FIXME: Tis shouldn't be necessary here, but there is a flush * missing in the MMU code. Until we find this bug, flush the
@@ -1305,14 +1298,12 @@ static int io_interception(struct vcpu_sstatic int nmi_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (NMI , &svm->vcpu, handler);return 1 ; }static int intr_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { ++svm->vcpu.stat.irq_exits; -KVMTRACE_0D (INTR , &svm->vcpu, handler);return 1 ; }
@@ -2079,8 +2070,7 @@ static int rdmsr_interception(struct vcpif (svm_get_msr (&svm->vcpu, ecx, &data))kvm_inject_gp (&svm->vcpu,0 );else { -KVMTRACE_3D (MSR_READ , &svm->vcpu, ecx, (u32 )data, - (u32)(data >>32 ), handler); +trace_kvm_msr_read (ecx, data); svm->vcpu.arch.regs[VCPU_REGS_RAX ] = data &0xffffffff ; svm->vcpu.arch.regs[VCPU_REGS_RDX ] = data >>32 ;
@@ -2158,8 +2148,7 @@ static int wrmsr_interception(struct vcpu64 data = (svm->vcpu.arch.regs[VCPU_REGS_RAX ] &-1u ) | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX ] &-1u ) <<32 ); -KVMTRACE_3D (MSR_WRITE , &svm->vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_write (ecx, data); svm->next_rip =kvm_rip_read (&svm->vcpu) +2 ;if (svm_set_msr (&svm->vcpu, ecx, data))
@@ -2180,8 +2169,6 @@ static int msr_interception(struct vcpu_static int interrupt_window_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (PEND_INTR , &svm->vcpu, handler); -svm_clear_vintr (svm); svm->vmcb->control.int_ctl &= ~V_IRQ_MASK ;/*
@@ -2260,8 +2247,7 @@ static int handle_exit(struct kvm_run *kstruct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; -KVMTRACE_3D (VMEXIT , vcpu, exit_code, (u32 )svm->vmcb->save.rip, - (u32)((u64 )svm->vmcb->save.rip >>32 ), entryexit); +trace_kvm_exit (exit_code, svm->vmcb->save.rip);if (is_nested (svm)) { nsvm_printk("nested handle_exit: 0x%x | 0x%lx | 0x%lx | 0x%lx\n",
@@ -2349,7 +2335,7 @@ static inline void svm_inject_irq(struct {struct vmcb_control_area *control; -KVMTRACE_1D (INJ_VIRQ , &svm->vcpu, (u32 )irq, handler); +trace_kvm_inj_virq (irq); ++svm->vcpu.stat.irq_injections; control = &svm->vmcb->control;
arch/x86/kvm/vmx-trace.h new file +22 -0
@@ -0,0 +1,22 @@ +#define exit_reasons vmx_exit_reasons +#define vmx_exit_reasons \ + {EXIT_REASON_EXCEPTION_NMI, "exception"}, \ + {EXIT_REASON_EXTERNAL_INTERRUPT, "ext_irq"}, \ + {EXIT_REASON_TRIPLE_FAULT, "triple_fault"}, \ + {EXIT_REASON_NMI_WINDOW, "nmi_window"}, \ + {EXIT_REASON_IO_INSTRUCTION, "io_instruction"}, \ + {EXIT_REASON_CR_ACCESS, "cr_access"}, \ + {EXIT_REASON_DR_ACCESS, "dr_access"}, \ + {EXIT_REASON_CPUID, "cpuid"}, \ + {EXIT_REASON_MSR_READ, "rdmsr"}, \ + {EXIT_REASON_MSR_WRITE, "wrmsr"}, \ + {EXIT_REASON_PENDING_INTERRUPT, "interrupt_window"}, \ + {EXIT_REASON_HLT, "halt"}, \ + {EXIT_REASON_INVLPG, "invlpg"}, \ + {EXIT_REASON_VMCALL, "hypercall"}, \ + {EXIT_REASON_TPR_BELOW_THRESHOLD, "tpr_below_thres"}, \ + {EXIT_REASON_APIC_ACCESS, "apic_access"}, \ + {EXIT_REASON_WBINVD, "wbinvd"}, \ + {EXIT_REASON_TASK_SWITCH, "task_switch"}, \ + {EXIT_REASON_EPT_VIOLATION, "ept_violation"} +
arch/x86/kvm/vmx.c +22 -32
162 lines not on this page · raw message
arch/x86/kvm/x86.c +13 -29
108 lines not on this page · raw message
include/trace/events/kvm/x86-arch.h new file +128 -0
128 lines not on this page · raw message
include/trace/events/kvm/x86.h new file +143 -0
143 lines not on this page · raw message
include/trace/events/kvm/kvm.h new file +55 -0
55 lines not on this page · raw message
virt/kvm/irq_comm.c +5 -0
@@ -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 irqunsigned 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 *kvstruct 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) {
virt/kvm/kvm_main.c +4 -0
@@ -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);
Steven Rostedt
maintainerRe: [patch 1/2] KVM: convert custom marker based tracing to event traces
include/trace/events/kvm/x86-arch.h
Quoted 58 lines · Marcelo Tosatti
This allows use of the powerful ftrace infrastructure.
See
Documentation/trace/for usage information.Signed-off-by Marcelo Tosatti <[email protected]>Index:
kvm/arch/x86/kvm/svm.c
===================================================================arch/x86/kvm/svm.c +3
-0@@ -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
===================================================================arch/x86/kvm/vmx.c +4
-0@@ -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
===================================================================arch/x86/kvm/x86.c +2
-0@@ -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
===================================================================include/trace/events/kvm/x86-arch.h new file +0
-0
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
Quoted 393 lines
include/trace/events/kvm/x86-arch.h new file +128
-0@@ -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
===================================================================include/trace/events/kvm/x86.h new file +143
-0@@ -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
===================================================================include/trace/events/kvm/kvm.h new file +55
-0@@ -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
===================================================================virt/kvm/irq_comm.c +5
-0@@ -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 irqunsigned 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 *kvstruct 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
===================================================================virt/kvm/kvm_main.c +4
-0@@ -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);Signature · 1 line
--
Re: [patch 1/2] KVM: convert custom marker based tracing to event traces
Quoted 85 lines · Steven Rostedt
include/trace/events/kvm/x86-arch.h
Quoted 58 lines · Marcelo Tosatti
This allows use of the powerful ftrace infrastructure.
See
Documentation/trace/for usage information.Signed-off-by Marcelo Tosatti <[email protected]>Index:
kvm/arch/x86/kvm/svm.c
===================================================================arch/x86/kvm/svm.c +3
-0@@ -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
===================================================================arch/x86/kvm/vmx.c +4
-0@@ -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
===================================================================arch/x86/kvm/x86.c +2
-0@@ -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
===================================================================include/trace/events/kvm/x86-arch.h new file +0
-0One 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
Makefileadd: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.oin
trace.c:#define
CREATE_TRACE_POINTS
#include "trace.h"
#include "trace-arch.h"
Quoted 6 lines
Then have the
kvm/x86.hmoved totrace.h
and thekvm/arch-x86.hmove totrace-arch.hJust change the "
TRACE_INCLUDE_FILE" to include the proper name.-- Steve
Similar to http://patchwork.kernel.org/patch/23829/, but moving the x86 tracepoint definitions to arch/x86/kvm/ ?
I thought the point of include/trace/ was to have all tracepoints definitions in a single directory?
Steven Rostedt
maintainerRe: [patch 1/2] KVM: convert custom marker based tracing to event traces
Quoted 27 lines · Marcelo Tosatti
Quoted 27 lines
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
Makefileadd: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.oin
trace.c:#define
CREATE_TRACE_POINTS
#include "trace.h"
#include "trace-arch.h"Then have the
kvm/x86.hmoved totrace.h
and thekvm/arch-x86.hmove totrace-arch.h
Quoted 6 lines
Quoted 3 lines
Just change the "
TRACE_INCLUDE_FILE" to include the proper name.-- Steve
Similar to http://patchwork.kernel.org/patch/23829/, but moving the x86 tracepoint definitions to
arch/x86/kvm/?
Yes, similar to what Christoph suggested.
Quoted 4 lines
I thought the point of
include/trace/was to have all tracepoints definitions in a single directory?
That's not what I heard ;-)
It should only be for core kernel code. If you have trace points that are the same on most archs, then sure. But if it is specific to one arch, then we are going to end up with arch code scattered through out the kernel again. I thought the idea of moving include/asm-x86 into arch/x86/include/asm was to consolidate arch code to one location?
Thus, if a trace point is made for one arch, then it should be located in that arch.
-- Steve
cover replace kvmtrace with event traces v2
PATCH 1/2 KVM: convert custom marker based tracing to event traces
This allows use of the powerful ftrace infrastructure.
See Documentation/trace/ for usage information.
arch/x86/kvm/lapic.c +4 -3
@@ -34,6 +34,7 @@#include <asm/atomic.h> #include "kvm_cache_regs.h" #include "irq.h" +#include "trace.h" #ifndef CONFIG_X86_64 #define mod_64 (x, y) ((x) - (y) * div64_u64(x, y))
@@ -515,8 +516,6 @@ static u32 __apic_read(struct kvm_lapic {u32 val =0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); -if (offset >=LAPIC_MMIO_LENGTH )return 0 ;
@@ -562,6 +561,8 @@ static void apic_mmio_read(struct kvm_io } result =__apic_read (apic, offset & ~0xf ); +trace_kvm_apic_read (offset, result); +switch (len) {case 1 :case 2 :
@@ -657,7 +658,7 @@ static void apic_mmio_write(struct kvm_i offset &=0xff0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); +trace_kvm_apic_write (offset, val);switch (offset) {case APIC_ID :/* Local APIC ID */
arch/x86/kvm/svm-trace.h new file +51 -0
51 lines not on this page · raw message
arch/x86/kvm/svm.c +8 -22
@@ -29,6 +29,9 @@#include <asm/desc.h> #include <asm/virtext.h> +#include "svm-trace.h" +#define CREATE_TRACE_POINTS +#include "trace-arch.h" #define __ex (x) __kvm_handle_fault_on_reboot(x)
@@ -1099,7 +1102,6 @@ static unsigned long svm_get_dr(struct k val =0 ; } -KVMTRACE_2D (DR_READ , vcpu, (u32 )dr, (u32 )val, handler);return val; }
@@ -1108,8 +1110,6 @@ static void svm_set_dr(struct kvm_vcpu * {struct vcpu_svm *svm =to_svm (vcpu); -KVMTRACE_2D (DR_WRITE , vcpu, (u32 )dr, (u32 )value, handler); - *exception =0 ;switch (dr) {
@@ -1157,14 +1157,7 @@ static int pf_interception(struct vcpu_s fault_address = svm->vmcb->control.exit_info_2; error_code = svm->vmcb->control.exit_info_1; -if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); -else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);/* * FIXME: Tis shouldn't be necessary here, but there is a flush * missing in the MMU code. Until we find this bug, flush the
@@ -1291,14 +1284,12 @@ static int io_interception(struct vcpu_sstatic int nmi_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (NMI , &svm->vcpu, handler);return 1 ; }static int intr_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { ++svm->vcpu.stat.irq_exits; -KVMTRACE_0D (INTR , &svm->vcpu, handler);return 1 ; }
@@ -2080,8 +2071,7 @@ static int rdmsr_interception(struct vcpif (svm_get_msr (&svm->vcpu, ecx, &data))kvm_inject_gp (&svm->vcpu,0 );else { -KVMTRACE_3D (MSR_READ , &svm->vcpu, ecx, (u32 )data, - (u32)(data >>32 ), handler); +trace_kvm_msr_read (ecx, data); svm->vcpu.arch.regs[VCPU_REGS_RAX ] = data &0xffffffff ; svm->vcpu.arch.regs[VCPU_REGS_RDX ] = data >>32 ;
@@ -2164,8 +2154,7 @@ static int wrmsr_interception(struct vcpu64 data = (svm->vcpu.arch.regs[VCPU_REGS_RAX ] &-1u ) | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX ] &-1u ) <<32 ); -KVMTRACE_3D (MSR_WRITE , &svm->vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_write (ecx, data); svm->next_rip =kvm_rip_read (&svm->vcpu) +2 ;if (svm_set_msr (&svm->vcpu, ecx, data))
@@ -2186,8 +2175,6 @@ static int msr_interception(struct vcpu_static int interrupt_window_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (PEND_INTR , &svm->vcpu, handler); -svm_clear_vintr (svm); svm->vmcb->control.int_ctl &= ~V_IRQ_MASK ;/*
@@ -2266,8 +2253,7 @@ static int handle_exit(struct kvm_run *kstruct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; -KVMTRACE_3D (VMEXIT , vcpu, exit_code, (u32 )svm->vmcb->save.rip, - (u32)((u64 )svm->vmcb->save.rip >>32 ), entryexit); +trace_kvm_exit (exit_code, svm->vmcb->save.rip);if (is_nested (svm)) { nsvm_printk("nested handle_exit: 0x%x | 0x%lx | 0x%lx | 0x%lx\n",
@@ -2355,7 +2341,7 @@ static inline void svm_inject_irq(struct {struct vmcb_control_area *control; -KVMTRACE_1D (INJ_VIRQ , &svm->vcpu, (u32 )irq, handler); +trace_kvm_inj_virq (irq); ++svm->vcpu.stat.irq_injections; control = &svm->vmcb->control;
arch/x86/kvm/vmx-trace.h new file +22 -0
@@ -0,0 +1,22 @@ +#define exit_reasons vmx_exit_reasons +#define vmx_exit_reasons \ + {EXIT_REASON_EXCEPTION_NMI, "exception"}, \ + {EXIT_REASON_EXTERNAL_INTERRUPT, "ext_irq"}, \ + {EXIT_REASON_TRIPLE_FAULT, "triple_fault"}, \ + {EXIT_REASON_NMI_WINDOW, "nmi_window"}, \ + {EXIT_REASON_IO_INSTRUCTION, "io_instruction"}, \ + {EXIT_REASON_CR_ACCESS, "cr_access"}, \ + {EXIT_REASON_DR_ACCESS, "dr_access"}, \ + {EXIT_REASON_CPUID, "cpuid"}, \ + {EXIT_REASON_MSR_READ, "rdmsr"}, \ + {EXIT_REASON_MSR_WRITE, "wrmsr"}, \ + {EXIT_REASON_PENDING_INTERRUPT, "interrupt_window"}, \ + {EXIT_REASON_HLT, "halt"}, \ + {EXIT_REASON_INVLPG, "invlpg"}, \ + {EXIT_REASON_VMCALL, "hypercall"}, \ + {EXIT_REASON_TPR_BELOW_THRESHOLD, "tpr_below_thres"}, \ + {EXIT_REASON_APIC_ACCESS, "apic_access"}, \ + {EXIT_REASON_WBINVD, "wbinvd"}, \ + {EXIT_REASON_TASK_SWITCH, "task_switch"}, \ + {EXIT_REASON_EPT_VIOLATION, "ept_violation"} +
arch/x86/kvm/vmx.c +22 -32
162 lines not on this page · raw message
arch/x86/kvm/x86.c +13 -29
108 lines not on this page · raw message
virt/kvm/irq_comm.c +5 -0
@@ -20,6 +20,7 @@*/ #include <linux/kvm_host.h> +#include <trace/events/kvm.h> #include <asm/msidef.h> #ifdef CONFIG_IA64
@@ -125,6 +126,8 @@ int kvm_set_irq(struct kvm *kvm, int irqunsigned 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 *kvstruct 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) {
virt/kvm/kvm_main.c +4 -0
@@ -59,6 +59,9 @@#include "irq.h" #endif +#define CREATE_TRACE_POINTS +#include <trace/events/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);
arch/x86/kvm/Makefile +4 -0
@@ -1,6 +1,10 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm +CFLAGS_x86.o := -I. +CFLAGS_svm.o := -I. +CFLAGS_vmx.o := -I. + kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
arch/x86/kvm/trace-arch.h new file +129 -0
129 lines not on this page · raw message
arch/x86/kvm/trace.h new file +144 -0
144 lines not on this page · raw message
include/trace/events/kvm.h new file +55 -0
55 lines not on this page · raw message
Re: [patch 1/2] KVM: convert custom marker based tracing to event traces
Quoted 5 lines · Marcelo Tosatti
This allows use of the powerful ftrace infrastructure.
See
Documentation/trace/for usage information.
This only applied with -C0, so I'm worried something's broken. Please regenerate.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
cover replace kvmtrace with event traces rebased
PATCH 1/2 KVM: convert custom marker based tracing to event traces
This allows use of the powerful ftrace infrastructure.
See Documentation/trace/ for usage information.
arch/x86/kvm/lapic.c +4 -3
@@ -34,6 +34,7 @@#include <asm/atomic.h> #include "kvm_cache_regs.h" #include "irq.h" +#include "trace.h" #ifndef CONFIG_X86_64 #define mod_64 (x, y) ((x) - (y) * div64_u64(x, y))
@@ -515,8 +516,6 @@ static u32 __apic_read(struct kvm_lapic {u32 val =0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); -if (offset >=LAPIC_MMIO_LENGTH )return 0 ;
@@ -562,6 +561,8 @@ static void apic_mmio_read(struct kvm_io } result =__apic_read (apic, offset & ~0xf ); +trace_kvm_apic_read (offset, result); +switch (len) {case 1 :case 2 :
@@ -657,7 +658,7 @@ static void apic_mmio_write(struct kvm_i offset &=0xff0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); +trace_kvm_apic_write (offset, val);switch (offset) {case APIC_ID :/* Local APIC ID */
arch/x86/kvm/svm-trace.h new file +51 -0
51 lines not on this page · raw message
arch/x86/kvm/svm.c +8 -23
@@ -29,6 +29,9 @@#include <asm/desc.h> #include <asm/virtext.h> +#include "svm-trace.h" +#define CREATE_TRACE_POINTS +#include "trace-arch.h" #define __ex (x) __kvm_handle_fault_on_reboot(x)
@@ -1099,7 +1102,6 @@ static unsigned long svm_get_dr(struct k val =0 ; } -KVMTRACE_2D (DR_READ , vcpu, (u32 )dr, (u32 )val, handler);return val; }
@@ -1108,8 +1110,6 @@ static void svm_set_dr(struct kvm_vcpu * {struct vcpu_svm *svm =to_svm (vcpu); -KVMTRACE_2D (DR_WRITE , vcpu, (u32 )dr, (u32 )value, handler); - *exception =0 ;switch (dr) {
@@ -1157,14 +1157,7 @@ static int pf_interception(struct vcpu_s fault_address = svm->vmcb->control.exit_info_2; error_code = svm->vmcb->control.exit_info_1; -if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); -else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);/* * FIXME: Tis shouldn't be necessary here, but there is a flush * missing in the MMU code. Until we find this bug, flush the
@@ -1291,14 +1284,12 @@ static int io_interception(struct vcpu_sstatic int nmi_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (NMI , &svm->vcpu, handler);return 1 ; }static int intr_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { ++svm->vcpu.stat.irq_exits; -KVMTRACE_0D (INTR , &svm->vcpu, handler);return 1 ; }
@@ -2080,8 +2071,7 @@ static int rdmsr_interception(struct vcpif (svm_get_msr (&svm->vcpu, ecx, &data))kvm_inject_gp (&svm->vcpu,0 );else { -KVMTRACE_3D (MSR_READ , &svm->vcpu, ecx, (u32 )data, - (u32)(data >>32 ), handler); +trace_kvm_msr_read (ecx, data); svm->vcpu.arch.regs[VCPU_REGS_RAX ] = data &0xffffffff ; svm->vcpu.arch.regs[VCPU_REGS_RDX ] = data >>32 ;
@@ -2149,7 +2139,6 @@ static int svm_set_msr(struct kvm_vcpu *break ;case MSR_VM_CR :case MSR_VM_IGNNE : -case MSR_K8_HWCR :pr_unimpl (vcpu,"unimplemented wrmsr: 0x%x data 0x%llx\n" , ecx, data);break ;default :
@@ -2164,8 +2153,7 @@ static int wrmsr_interception(struct vcpu64 data = (svm->vcpu.arch.regs[VCPU_REGS_RAX ] &-1u ) | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX ] &-1u ) <<32 ); -KVMTRACE_3D (MSR_WRITE , &svm->vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_write (ecx, data); svm->next_rip =kvm_rip_read (&svm->vcpu) +2 ;if (svm_set_msr (&svm->vcpu, ecx, data))
@@ -2186,8 +2174,6 @@ static int msr_interception(struct vcpu_static int interrupt_window_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (PEND_INTR , &svm->vcpu, handler); -svm_clear_vintr (svm); svm->vmcb->control.int_ctl &= ~V_IRQ_MASK ;/*
@@ -2266,8 +2252,7 @@ static int handle_exit(struct kvm_run *kstruct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; -KVMTRACE_3D (VMEXIT , vcpu, exit_code, (u32 )svm->vmcb->save.rip, - (u32)((u64 )svm->vmcb->save.rip >>32 ), entryexit); +trace_kvm_exit (exit_code, svm->vmcb->save.rip);if (is_nested (svm)) { nsvm_printk("nested handle_exit: 0x%x | 0x%lx | 0x%lx | 0x%lx\n",
@@ -2355,7 +2340,7 @@ static inline void svm_inject_irq(struct {struct vmcb_control_area *control; -KVMTRACE_1D (INJ_VIRQ , &svm->vcpu, (u32 )irq, handler); +trace_kvm_inj_virq (irq); ++svm->vcpu.stat.irq_injections; control = &svm->vmcb->control;
arch/x86/kvm/vmx-trace.h new file +22 -0
@@ -0,0 +1,22 @@ +#define exit_reasons vmx_exit_reasons +#define vmx_exit_reasons \ + {EXIT_REASON_EXCEPTION_NMI, "exception"}, \ + {EXIT_REASON_EXTERNAL_INTERRUPT, "ext_irq"}, \ + {EXIT_REASON_TRIPLE_FAULT, "triple_fault"}, \ + {EXIT_REASON_NMI_WINDOW, "nmi_window"}, \ + {EXIT_REASON_IO_INSTRUCTION, "io_instruction"}, \ + {EXIT_REASON_CR_ACCESS, "cr_access"}, \ + {EXIT_REASON_DR_ACCESS, "dr_access"}, \ + {EXIT_REASON_CPUID, "cpuid"}, \ + {EXIT_REASON_MSR_READ, "rdmsr"}, \ + {EXIT_REASON_MSR_WRITE, "wrmsr"}, \ + {EXIT_REASON_PENDING_INTERRUPT, "interrupt_window"}, \ + {EXIT_REASON_HLT, "halt"}, \ + {EXIT_REASON_INVLPG, "invlpg"}, \ + {EXIT_REASON_VMCALL, "hypercall"}, \ + {EXIT_REASON_TPR_BELOW_THRESHOLD, "tpr_below_thres"}, \ + {EXIT_REASON_APIC_ACCESS, "apic_access"}, \ + {EXIT_REASON_WBINVD, "wbinvd"}, \ + {EXIT_REASON_TASK_SWITCH, "task_switch"}, \ + {EXIT_REASON_EPT_VIOLATION, "ept_violation"} +
arch/x86/kvm/vmx.c +22 -32
162 lines not on this page · raw message
arch/x86/kvm/x86.c +13 -29
108 lines not on this page · raw message
virt/kvm/irq_comm.c +5 -0
@@ -20,6 +20,7 @@*/ #include <linux/kvm_host.h> +#include <trace/events/kvm.h> #include <asm/msidef.h> #ifdef CONFIG_IA64
@@ -125,6 +126,8 @@ int kvm_set_irq(struct kvm *kvm, int irqunsigned 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 *kvstruct 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) {
virt/kvm/kvm_main.c +4 -0
@@ -59,6 +59,9 @@#include "irq.h" #endif +#define CREATE_TRACE_POINTS +#include <trace/events/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);
arch/x86/kvm/Makefile +4 -0
@@ -1,6 +1,10 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm +CFLAGS_x86.o := -I. +CFLAGS_svm.o := -I. +CFLAGS_vmx.o := -I. + kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
arch/x86/kvm/trace-arch.h new file +129 -0
129 lines not on this page · raw message
arch/x86/kvm/trace.h new file +144 -0
144 lines not on this page · raw message
include/trace/events/kvm.h new file +55 -0
55 lines not on this page · raw message
PATCH 2/2 KVM: remove old KVMTRACE support code
In reply to Marcelo TosattiReturn EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
virt/kvm/kvm_main.c +1 -2
@@ -2367,7 +2367,7 @@ static long kvm_dev_ioctl(struct file *fcase KVM_TRACE_ENABLE :case KVM_TRACE_PAUSE :case KVM_TRACE_DISABLE : - r =kvm_trace_ioctl (ioctl, arg); + r = -EOPNOTSUPP ;break ;default :return kvm_arch_dev_ioctl (filp, ioctl, arg);
@@ -2717,7 +2717,6 @@ 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);
include/linux/kvm_host.h +0 -31
@@ -482,37 +482,6 @@ struct kvm_stats_debugfs_item {extern struct kvm_stats_debugfs_item debugfs_entries[];extern struct dentry *kvm_debugfs_dir; -#define KVMTRACE_5D (evt, vcpu, d1, d2, d3, d4, d5, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 5, d1, d2, d3, d4, d5) -#define KVMTRACE_4D (evt, vcpu, d1, d2, d3, d4, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 4, d1, d2, d3, d4, 0) -#define KVMTRACE_3D (evt, vcpu, d1, d2, d3, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 3, d1, d2, d3, 0, 0) -#define KVMTRACE_2D (evt, vcpu, d1, d2, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 2, d1, d2, 0, 0, 0) -#define KVMTRACE_1D (evt, vcpu, d1, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 1, d1, 0, 0, 0, 0) -#define KVMTRACE_0D (evt, vcpu, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 0, 0, 0, 0, 0, 0) - -#ifdef CONFIG_KVM_TRACE -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg); -void kvm_trace_cleanup (void ); -#else -static inline -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg) -{ -return -EINVAL ; -} -#define kvm_trace_cleanup () ((void)0) -#endif -#ifdef KVM_ARCH_WANT_MMU_NOTIFIER static inline int mmu_notifier_retry (struct kvm_vcpu *vcpu,unsigned long mmu_seq) {
virt/kvm/kvm_trace.c deleted +0 -285
285 lines not on this page · raw message
arch/x86/kvm/Makefile +0 -1
@@ -7,7 +7,6 @@ CFLAGS_vmx.o := -I. kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) -kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o) kvm-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \
include/linux/kvm.h +1 -30
@@ -14,7 +14,7 @@#define KVM_API_VERSION 12 -/* for KVM_TRACE_ENABLE */ +/* for KVM_TRACE_ENABLE, deprecated */ struct kvm_user_trace_setup {__u32 buf_size;/* sub_buffer size of each per-cpu */ __u32 buf_nr;/* the number of sub_buffers of each per-cpu */
@@ -325,35 +325,6 @@ struct kvm_guest_debug {#define KVM_TRC_CYCLE_SIZE 8#define KVM_TRC_EXTRA_MAX 7 -/* This structure represents a single trace buffer record. */ -struct kvm_trace_rec { -/* variable rec_val -* is split into: -* bits 0 - 27 -> event id -* bits 28 -30 -> number of extra data args of size u32 -* bits 31 -> binary indicator for if tsc is in record -*/ -__u32 rec_val; -__u32 pid; -__u32 vcpu_id; -union { -struct { -__u64 timestamp; -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } __attribute__((packed)) timestamp; -struct { -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } notimestamp; - } u; -}; - -#define TRACE_REC_EVENT_ID (val) \ - (0x0fffffff & (val)) -#define TRACE_REC_NUM_DATA_ARGS (val) \ - (0x70000000 & ((val) << 28)) -#define TRACE_REC_TCS (val) \ - (0x80000000 & ((val) << 31)) -#define KVMIO 0xAE/*
arch/x86/kvm/Kconfig +0 -12
@@ -62,18 +62,6 @@ config KVM_AMD To compile this as a module, choose M here: the module will be called kvm-amd. -config KVM_TRACE - bool "KVM trace support" - depends on KVM && SYSFS - select MARKERS - select RELAY - select DEBUG_FS - default n - ---help--- - This option allows reading a trace of kvm-related events through - relayfs. Note the ABI is not considered stable and will be - modified in future updates. - # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. source drivers/lguest/Kconfig
Re: [patch 2/2] KVM: remove old KVMTRACE support code
Quoted 3 lines · Marcelo Tosatti
Return EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
I dropped this patch, breaks the powerpc build. I guess it should be simple to convert powerpc?
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
cover remove old KVMTRACE support code
PATCH 1/3 KVM: PPC: convert marker probes to event trace
arch/powerpc/kvm/44x_tlb.c +8 -5
@@ -31,6 +31,9 @@#include "44x_tlb.h" +#define CREATE_TRACE_POINTS +#include "trace-arch.h" +#ifndef PPC44x_TLBE_SIZE#define PPC44x_TLBE_SIZE PPC44x_TLB_4K#endif
@@ -263,7 +266,7 @@ static void kvmppc_44x_shadow_release(st/* XXX set tlb_44x_index to stlb_index? */ -KVMTRACE_1D (STLB_INVAL , &vcpu_44x->vcpu, stlb_index, handler); +trace_kvm_stlb_inval (stlb_index); }void kvmppc_mmu_destroy (struct kvm_vcpu *vcpu)
@@ -365,8 +368,8 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcp/* Insert shadow mapping into hardware TLB. */ kvmppc_44x_tlbe_set_modified (vcpu_44x, victim);kvmppc_44x_tlbwe (victim, &stlbe); -KVMTRACE_5D (STLB_WRITE , vcpu, victim, stlbe.tid, stlbe.word0, stlbe.word1, - stlbe.word2, handler); +trace_kvm_stlb_write (victim, stlbe.tid, stlbe.word0, stlbe.word1, + stlbe.word2); }/* For a particular guest TLB entry, invalidate the corresponding host TLB
@@ -485,8 +488,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpkvmppc_mmu_map (vcpu, eaddr, gpaddr, gtlb_index); } -KVMTRACE_5D (GTLB_WRITE , vcpu, gtlb_index, tlbe->tid, tlbe->word0, - tlbe->word1, tlbe->word2, handler); +trace_kvm_gtlb_write (gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1, + tlbe->word2);kvmppc_set_exit_type (vcpu,EMULATED_TLBWE_EXITS );return EMULATE_DONE ;
arch/powerpc/kvm/trace-arch.h new file +84 -0
84 lines not on this page · raw message
arch/powerpc/kvm/Makefile +4 -0
@@ -8,6 +8,10 @@ common-objs-y = $(addprefix ../../../vir common-objs-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) +CFLAGS_44x_tlb.o := -I. +CFLAGS_e500_tlb.o := -I. +CFLAGS_emulate.o := -I. + kvm-objs := $(common-objs-y) powerpc.o emulate.o obj-$(CONFIG_KVM_EXIT_TIMING) += timing.o obj-$(CONFIG_KVM) += kvm.o
arch/powerpc/kvm/e500_tlb.c +9 -9
@@ -23,6 +23,9 @@#include "../mm/mmu_decl.h" #include "e500_tlb.h" +#define CREATE_TRACE_POINTS +#include "trace-arch.h" +#define to_htlb1_esel (esel) (tlb1_entry_num - (esel) - 1)static unsigned int tlb1_entry_num;
@@ -224,9 +227,8 @@ static void kvmppc_e500_stlbe_invalidatekvmppc_e500_shadow_release (vcpu_e500, tlbsel, esel); stlbe->mas1 =0 ; -KVMTRACE_5D (STLB_INVAL , &vcpu_e500->vcpu,index_of (tlbsel, esel), - stlbe->mas1, stlbe->mas2, stlbe->mas3, stlbe->mas7, - handler); +trace_kvm_stlb_inval (index_of (tlbsel, esel), stlbe->mas1, stlbe->mas2, + stlbe->mas3, stlbe->mas7); } static void kvmppc_e500_tlb1_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
@@ -319,9 +321,8 @@ static inline void kvmppc_e500_shadow_ma vcpu_e500->vcpu.arch.msr & MSR_PR); stlbe->mas7 = (hpaddr >>32 ) &MAS7_RPN ; -KVMTRACE_5D (STLB_WRITE , &vcpu_e500->vcpu,index_of (tlbsel, esel), - stlbe->mas1, stlbe->mas2, stlbe->mas3, stlbe->mas7, - handler); +trace_kvm_stlb_write (index_of (tlbsel, esel), stlbe->mas1, stlbe->mas2, + stlbe->mas3, stlbe->mas7); }/* XXX only map the one-one case, for now use TLB0 */
@@ -535,9 +536,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vc gtlbe->mas3 = vcpu_e500->mas3; gtlbe->mas7 = vcpu_e500->mas7; -KVMTRACE_5D (GTLB_WRITE , vcpu, vcpu_e500->mas0, - gtlbe->mas1, gtlbe->mas2, gtlbe->mas3, gtlbe->mas7, - handler); +trace_kvm_gtlb_write (vcpu_e500->mas0, gtlbe->mas1, gtlbe->mas2, + gtlbe->mas3, gtlbe->mas7);/* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ if (tlbe_is_host_safe (vcpu, gtlbe)) {
arch/powerpc/kvm/emulate.c +4 -1
@@ -30,6 +30,9 @@#include <asm/disassemble.h> #include "timing.h" +#define CREATE_TRACE_POINTS +#include "trace.h" +#define OP_TRAP 3#define OP_31_XOP_LWZX 23
@@ -419,7 +422,7 @@ int kvmppc_emulate_instruction(struct kv } } -KVMTRACE_3D (PPC_INSTR , vcpu, inst, (int )vcpu->arch.pc, emulated, entryexit); +trace_kvm_ppc_instr (inst, vcpu->arch.pc, emulated);if (advance) vcpu->arch.pc +=4 ;/* Advance past emulated instruction. */
arch/powerpc/kvm/trace.h new file +37 -0
@@ -0,0 +1,37 @@ +#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_PATH arch/powerpc/kvm +#define TRACE_INCLUDE_FILE trace + +/* +* Tracepoint for guest mode entry. +*/ +TRACE_EVENT(kvm_ppc_instr +TP_PROTO (unsigned int inst,unsigned long pc,unsigned int emulate), +TP_ARGS (inst, pc, emulate), + +TP_STRUCT__entry ( + __field( unsigned int, inst ) +__field (unsigned long ,pc ) + __field( unsigned int, emulate ) + ), + +TP_fast_assign ( + __entry->inst = inst; + __entry->pc = pc; + __entry->emulate = emulate; + ), + +TP_printk ("inst %u pc 0x%lx emulate %u\n" , + __entry->inst, __entry->pc, __entry->emulate); +); + +#endif /* _TRACE_KVM_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>
PATCH 2/3 KVM: remove old KVMTRACE support code
In reply to Marcelo TosattiReturn EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
virt/kvm/kvm_main.c +1 -2
@@ -2367,7 +2367,7 @@ static long kvm_dev_ioctl(struct file *fcase KVM_TRACE_ENABLE :case KVM_TRACE_PAUSE :case KVM_TRACE_DISABLE : - r =kvm_trace_ioctl (ioctl, arg); + r = -EOPNOTSUPP ;break ;default :return kvm_arch_dev_ioctl (filp, ioctl, arg);
@@ -2717,7 +2717,6 @@ 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);
include/linux/kvm_host.h +0 -31
@@ -482,37 +482,6 @@ struct kvm_stats_debugfs_item {extern struct kvm_stats_debugfs_item debugfs_entries[];extern struct dentry *kvm_debugfs_dir; -#define KVMTRACE_5D (evt, vcpu, d1, d2, d3, d4, d5, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 5, d1, d2, d3, d4, d5) -#define KVMTRACE_4D (evt, vcpu, d1, d2, d3, d4, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 4, d1, d2, d3, d4, 0) -#define KVMTRACE_3D (evt, vcpu, d1, d2, d3, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 3, d1, d2, d3, 0, 0) -#define KVMTRACE_2D (evt, vcpu, d1, d2, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 2, d1, d2, 0, 0, 0) -#define KVMTRACE_1D (evt, vcpu, d1, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 1, d1, 0, 0, 0, 0) -#define KVMTRACE_0D (evt, vcpu, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 0, 0, 0, 0, 0, 0) - -#ifdef CONFIG_KVM_TRACE -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg); -void kvm_trace_cleanup (void ); -#else -static inline -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg) -{ -return -EINVAL ; -} -#define kvm_trace_cleanup () ((void)0) -#endif -#ifdef KVM_ARCH_WANT_MMU_NOTIFIER static inline int mmu_notifier_retry (struct kvm_vcpu *vcpu,unsigned long mmu_seq) {
virt/kvm/kvm_trace.c deleted +0 -285
285 lines not on this page · raw message
arch/x86/kvm/Makefile +0 -1
@@ -7,7 +7,6 @@ CFLAGS_vmx.o := -I. kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) -kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o) kvm-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \
include/linux/kvm.h +1 -30
@@ -14,7 +14,7 @@#define KVM_API_VERSION 12 -/* for KVM_TRACE_ENABLE */ +/* for KVM_TRACE_ENABLE, deprecated */ struct kvm_user_trace_setup {__u32 buf_size;/* sub_buffer size of each per-cpu */ __u32 buf_nr;/* the number of sub_buffers of each per-cpu */
@@ -325,35 +325,6 @@ struct kvm_guest_debug {#define KVM_TRC_CYCLE_SIZE 8#define KVM_TRC_EXTRA_MAX 7 -/* This structure represents a single trace buffer record. */ -struct kvm_trace_rec { -/* variable rec_val -* is split into: -* bits 0 - 27 -> event id -* bits 28 -30 -> number of extra data args of size u32 -* bits 31 -> binary indicator for if tsc is in record -*/ -__u32 rec_val; -__u32 pid; -__u32 vcpu_id; -union { -struct { -__u64 timestamp; -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } __attribute__((packed)) timestamp; -struct { -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } notimestamp; - } u; -}; - -#define TRACE_REC_EVENT_ID (val) \ - (0x0fffffff & (val)) -#define TRACE_REC_NUM_DATA_ARGS (val) \ - (0x70000000 & ((val) << 28)) -#define TRACE_REC_TCS (val) \ - (0x80000000 & ((val) << 31)) -#define KVMIO 0xAE/*
arch/x86/kvm/Kconfig +0 -12
@@ -62,18 +62,6 @@ config KVM_AMD To compile this as a module, choose M here: the module will be called kvm-amd. -config KVM_TRACE - bool "KVM trace support" - depends on KVM && SYSFS - select MARKERS - select RELAY - select DEBUG_FS - default n - ---help--- - This option allows reading a trace of kvm-related events through - relayfs. Note the ABI is not considered stable and will be - modified in future updates. - # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. source drivers/lguest/Kconfig
arch/ia64/kvm/Kconfig +0 -3
@@ -47,9 +47,6 @@ config KVM_INTEL Provides support for KVM on Itanium 2 processors equipped with the VT extensions. -config KVM_TRACE - bool - source drivers/virtio/Kconfig endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -11
@@ -58,17 +58,6 @@ config KVM_E500 If unsure, say N. -config KVM_TRACE - bool "KVM trace support" - depends on KVM && MARKERS && SYSFS - select RELAY - select DEBUG_FS - default n - ---help--- - This option allows reading a trace of kvm-related events through - relayfs. Note the ABI is not considered stable and will be - modified in future updates. - source drivers/virtio/Kconfig endif # VIRTUALIZATION
arch/powerpc/kvm/Makefile +0 -2
@@ -6,8 +6,6 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerp common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o) -common-objs-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) - CFLAGS_44x_tlb.o := -I. CFLAGS_e500_tlb.o := -I. CFLAGS_emulate.o := -I.
arch/s390/kvm/Kconfig +0 -3
@@ -34,9 +34,6 @@ config KVM If unsure, say N. -config KVM_TRACE - bool - # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. source drivers/virtio/Kconfig
PATCH 3/3 kvm-kmod: dummy event trace hooks
In reply to Marcelo TosattiAnd don't stop if kvm_trace.c is gone.
external-module-compat-comm.h +12 -0
@@ -762,6 +762,18 @@ static inline bool zalloc_cpumask_var(cp#endif +/* event traces added in 2.6.31 */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,31 ) + +#define TP_PROTO(args...) args + +#define TRACE_EVENT (name, proto, args, entry, fa, printk) \ + static inline void trace_##name(proto) { } + +static inline void tracepoint_synchronize_unregister (void ) { } + +#endif +/* Macro introduced only on newer kernels: */ #if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,28 )
sync +11 -1
@@ -171,6 +171,10 @@ def header_sync(arch): % { 'T': T, 'name': os.path.basename(file) }) cp(file, out) unifdef(out) + for file in glob('%(linux)s/include/trace/events/kvm.h' % { 'linux': linux }): + out = ('%(T)s/include/trace/events/%(name)s' + % { 'T': T, 'name': os.path.basename(file) }) + cp(file, out) arch_headers = ( [x for dir in ['%(linux)s/arch/%(arch)s/include/asm/./kvm*.h',
@@ -207,7 +211,13 @@ def source_sync(arch): unifdef(i) for i in hack_files[arch]: - hack(T, arch, i) + try: + os.stat(T + "/" + i ) + except OSError: + if i != "kvm_trace.c": + raise + else: + hack(T, arch, i) copy_if_changed(T, arch) rmtree(T)
include-compat/trace/define_trace.h new file +1 -0
@@ -0,0 +1 @@ +/* Dummy file */
Re: [patch 0/3] remove old KVMTRACE support code
In reply to Marcelo TosattiOn 06/18/2009 05:47 PM, Marcelo Tosatti wrote:
Applied 1 and 2. I folded trace-arch.h into trace.h because trace-arch.h gave me grief on x86. Patch 3 likely will not apply since there were many changes in that area; I'll hack it enough so it builds.
We could probably remove arch/powerpc/kvm/timing.h. I'd also like to kill kvm_stat (and implement it on top of markers), but I'd like some hack so it can work on older kernels.
Signature · 1 line
error compiling committee.c: too many arguments to function
Avi Kivity
AppliedRe: [patch 0/2] replace kvmtrace with event traces rebased
In reply to Marcelo TosattiOn 06/17/2009 03:22 PM, Marcelo Tosatti wrote:
Applied, thanks.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
PATCH 2/2 KVM: remove old KVMTRACE support code
In reply to Marcelo TosattiReturn EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
virt/kvm/kvm_main.c +1 -2
@@ -2367,7 +2367,7 @@ static long kvm_dev_ioctl(struct file *fcase KVM_TRACE_ENABLE :case KVM_TRACE_PAUSE :case KVM_TRACE_DISABLE : - r =kvm_trace_ioctl (ioctl, arg); + r = -EOPNOTSUPP ;break ;default :return kvm_arch_dev_ioctl (filp, ioctl, arg);
@@ -2717,7 +2717,6 @@ 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);
include/linux/kvm_host.h +0 -31
@@ -482,37 +482,6 @@ struct kvm_stats_debugfs_item {extern struct kvm_stats_debugfs_item debugfs_entries[];extern struct dentry *kvm_debugfs_dir; -#define KVMTRACE_5D (evt, vcpu, d1, d2, d3, d4, d5, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 5, d1, d2, d3, d4, d5) -#define KVMTRACE_4D (evt, vcpu, d1, d2, d3, d4, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 4, d1, d2, d3, d4, 0) -#define KVMTRACE_3D (evt, vcpu, d1, d2, d3, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 3, d1, d2, d3, 0, 0) -#define KVMTRACE_2D (evt, vcpu, d1, d2, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 2, d1, d2, 0, 0, 0) -#define KVMTRACE_1D (evt, vcpu, d1, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 1, d1, 0, 0, 0, 0) -#define KVMTRACE_0D (evt, vcpu, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 0, 0, 0, 0, 0, 0) - -#ifdef CONFIG_KVM_TRACE -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg); -void kvm_trace_cleanup (void ); -#else -static inline -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg) -{ -return -EINVAL ; -} -#define kvm_trace_cleanup () ((void)0) -#endif -#ifdef KVM_ARCH_WANT_MMU_NOTIFIER static inline int mmu_notifier_retry (struct kvm_vcpu *vcpu,unsigned long mmu_seq) {
virt/kvm/kvm_trace.c deleted +0 -285
285 lines not on this page · raw message
arch/x86/kvm/Makefile +0 -1
@@ -7,7 +7,6 @@ CFLAGS_vmx.o := -I. kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) -kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o) kvm-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \
include/linux/kvm.h +1 -30
@@ -14,7 +14,7 @@#define KVM_API_VERSION 12 -/* for KVM_TRACE_ENABLE */ +/* for KVM_TRACE_ENABLE, deprecated */ struct kvm_user_trace_setup {__u32 buf_size;/* sub_buffer size of each per-cpu */ __u32 buf_nr;/* the number of sub_buffers of each per-cpu */
@@ -325,35 +325,6 @@ struct kvm_guest_debug {#define KVM_TRC_CYCLE_SIZE 8#define KVM_TRC_EXTRA_MAX 7 -/* This structure represents a single trace buffer record. */ -struct kvm_trace_rec { -/* variable rec_val -* is split into: -* bits 0 - 27 -> event id -* bits 28 -30 -> number of extra data args of size u32 -* bits 31 -> binary indicator for if tsc is in record -*/ -__u32 rec_val; -__u32 pid; -__u32 vcpu_id; -union { -struct { -__u64 timestamp; -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } __attribute__((packed)) timestamp; -struct { -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } notimestamp; - } u; -}; - -#define TRACE_REC_EVENT_ID (val) \ - (0x0fffffff & (val)) -#define TRACE_REC_NUM_DATA_ARGS (val) \ - (0x70000000 & ((val) << 28)) -#define TRACE_REC_TCS (val) \ - (0x80000000 & ((val) << 31)) -#define KVMIO 0xAE/*
arch/x86/kvm/Kconfig +0 -12
@@ -62,18 +62,6 @@ config KVM_AMD To compile this as a module, choose M here: the module will be called kvm-amd. -config KVM_TRACE - bool "KVM trace support" - depends on KVM && SYSFS - select MARKERS - select RELAY - select DEBUG_FS - default n - ---help--- - This option allows reading a trace of kvm-related events through - relayfs. Note the ABI is not considered stable and will be - modified in future updates. - # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. source drivers/lguest/Kconfig
Re: [patch 2/2] KVM: remove old KVMTRACE support code
Quoted 3 lines · Marcelo Tosatti
Return EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
The first feature we remove, we don't have a KVM_CAP for.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
PATCH 2/2 KVM: remove old KVMTRACE support code
In reply to Marcelo TosattiReturn EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.
virt/kvm/kvm_main.c +1 -2
@@ -2367,7 +2367,7 @@ static long kvm_dev_ioctl(struct file *fcase KVM_TRACE_ENABLE :case KVM_TRACE_PAUSE :case KVM_TRACE_DISABLE : - r =kvm_trace_ioctl (ioctl, arg); + r = -EOPNOTSUPP ;break ;default :return kvm_arch_dev_ioctl (filp, ioctl, arg);
@@ -2717,7 +2717,6 @@ 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);
include/linux/kvm_host.h +0 -31
@@ -482,37 +482,6 @@ struct kvm_stats_debugfs_item {extern struct kvm_stats_debugfs_item debugfs_entries[];extern struct dentry *kvm_debugfs_dir; -#define KVMTRACE_5D (evt, vcpu, d1, d2, d3, d4, d5, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 5, d1, d2, d3, d4, d5) -#define KVMTRACE_4D (evt, vcpu, d1, d2, d3, d4, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 4, d1, d2, d3, d4, 0) -#define KVMTRACE_3D (evt, vcpu, d1, d2, d3, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 3, d1, d2, d3, 0, 0) -#define KVMTRACE_2D (evt, vcpu, d1, d2, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 2, d1, d2, 0, 0, 0) -#define KVMTRACE_1D (evt, vcpu, d1, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 1, d1, 0, 0, 0, 0) -#define KVMTRACE_0D (evt, vcpu, name) \ - trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ - vcpu, 0, 0, 0, 0, 0, 0) - -#ifdef CONFIG_KVM_TRACE -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg); -void kvm_trace_cleanup (void ); -#else -static inline -int kvm_trace_ioctl (unsigned int ioctl,unsigned long arg) -{ -return -EINVAL ; -} -#define kvm_trace_cleanup () ((void)0) -#endif -#ifdef KVM_ARCH_WANT_MMU_NOTIFIER static inline int mmu_notifier_retry (struct kvm_vcpu *vcpu,unsigned long mmu_seq) {
virt/kvm/kvm_trace.c deleted +0 -285
285 lines not on this page · raw message
arch/x86/kvm/Makefile +0 -1
@@ -3,7 +3,6 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kv kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ coalesced_mmio.o irq_comm.o eventfd.o) -kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o) kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o) kvm-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \
include/linux/kvm.h +1 -30
@@ -14,7 +14,7 @@#define KVM_API_VERSION 12 -/* for KVM_TRACE_ENABLE */ +/* for KVM_TRACE_ENABLE, deprecated */ struct kvm_user_trace_setup {__u32 buf_size;/* sub_buffer size of each per-cpu */ __u32 buf_nr;/* the number of sub_buffers of each per-cpu */
@@ -325,35 +325,6 @@ struct kvm_guest_debug {#define KVM_TRC_CYCLE_SIZE 8#define KVM_TRC_EXTRA_MAX 7 -/* This structure represents a single trace buffer record. */ -struct kvm_trace_rec { -/* variable rec_val -* is split into: -* bits 0 - 27 -> event id -* bits 28 -30 -> number of extra data args of size u32 -* bits 31 -> binary indicator for if tsc is in record -*/ -__u32 rec_val; -__u32 pid; -__u32 vcpu_id; -union { -struct { -__u64 timestamp; -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } __attribute__((packed)) timestamp; -struct { -__u32 extra_u32[KVM_TRC_EXTRA_MAX ]; - } notimestamp; - } u; -}; - -#define TRACE_REC_EVENT_ID (val) \ - (0x0fffffff & (val)) -#define TRACE_REC_NUM_DATA_ARGS (val) \ - (0x70000000 & ((val) << 28)) -#define TRACE_REC_TCS (val) \ - (0x80000000 & ((val) << 31)) -#define KVMIO 0xAE/*
arch/x86/kvm/Kconfig +0 -12
@@ -62,18 +62,6 @@ config KVM_AMD To compile this as a module, choose M here: the module will be called kvm-amd. -config KVM_TRACE - bool "KVM trace support" - depends on KVM && SYSFS - select MARKERS - select RELAY - select DEBUG_FS - default n - ---help--- - This option allows reading a trace of kvm-related events through - relayfs. Note the ABI is not considered stable and will be - modified in future updates. - # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. source drivers/lguest/Kconfig