Skip to contentSkip to conversation

add trace points in irqchip code

PATCH Superseded Gleb Natapov 2 participants 4 messages Jul 6, 2009 – Jul 7, 2009

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add trace points in irqchip code

Add tracepoint in msi/ioapic/pic set_irq() functions, in IPI sending and in the point where IRQ is placed into apic's IRR.

arch/x86/kvm/i8259.c +3 -0
index 1d1bb75..e4bcbdd 100644
@@ -30,6 +30,7 @@
 #include "irq.h"
 
 #include <linux/kvm_host.h>
+#include "trace.h"
 
 static void pic_lock(struct kvm_pic *s)
 	__acquires(&s->lock)
@@ -190,6 +191,8 @@ int kvm_pic_set_irq(void *opaque, int irq, int level)
 	if (irq >= 0 && irq < PIC_NUM_PINS) {
 		ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, level);
 		pic_update_irq(s);
+		trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr,
+				      s->pics[irq >> 3].imr, ret == 0);
 	}
 	pic_unlock(s);
 
arch/x86/kvm/lapic.c +4 -0
index 6f559d6..bd5cba9 100644
@@ -375,6 +375,8 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
 			break;
 
 		result = !apic_test_and_set_irr(vector, apic);
+		trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode,
+					  trig_mode, vector, result);
 		if (!result) {
 			if (trig_mode)
 				apic_debug("level trig mode repeatedly for "
@@ -493,6 +495,8 @@ static void apic_send_ipi(struct kvm_lapic *apic)
 	else
 		irq.dest_id = GET_APIC_DEST_FIELD(icr_high);
 
+	trace_kvm_apic_ipi(icr_low, irq.dest_id);
+
 	apic_debug("icr_high 0x%x, icr_low 0x%x, "
 		   "short_hand 0x%x, dest 0x%x, trig_mode 0x%x, level 0x%x, "
 		   "dest_mode 0x%x, delivery_mode 0x%x, vector 0x%x\n",
arch/x86/kvm/trace.h +85 -0

91 lines not on this page · raw message

include/trace/events/kvm.h +56 -0

62 lines not on this page · raw message

virt/kvm/ioapic.c +2 -0
index 92496ff..b91fbb2 100644
@@ -36,6 +36,7 @@
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/current.h>
+#include <trace/events/kvm.h>
 
 #include "ioapic.h"
 #include "lapic.h"
@@ -193,6 +194,7 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)
 			    (!edge && !entry.fields.remote_irr))
 				ret = ioapic_service(ioapic, irq);
 		}
+		trace_kvm_ioapic_set_irq(entry.bits, irq, ret == 0);
 	}
 	return ret;
 }
virt/kvm/irq_comm.c +2 -0
index c380bf0..43b692e 100644
@@ -100,6 +100,8 @@ static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 {
 	struct kvm_lapic_irq irq;
 
+	trace_kvm_msi_set_irq(e->msi.address_lo, e->msi.data);
+
 	irq.dest_id = (e->msi.address_lo &
 			MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT;
 	irq.vector = (e->msi.data &

--
Gleb.

#1 lore raw
Quoted 18 lines · Gleb Natapov

Add tracepoint in msi/ioapic/pic set_irq() functions, in IPI sending and in the point where IRQ is placed into apic's IRR.

arch/x86/kvm/i8259.c +1 -0
index 1d1bb75..e4bcbdd 100644
@@ -30,6 +30,7 @@
  #include "irq.h"
 
  #include<linux/kvm_host.h>
+#include "trace.h"
 
  static void pic_lock(struct kvm_pic *s)
  	__acquires(&s->lock)

arch/x86/kvm/i8259.c int kvm_pic_set_irq(void *opaque, int irq, int level) · line 196

Quoted 6 lines
arch/x86/kvm/i8259.c +2 -0
@@ -190,6 +191,8 @@ int kvm_pic_set_irq(void *opaque, int irq, int level)
  	if (irq>= 0&&  irq<  PIC_NUM_PINS) {
  		ret = pic_set_irq1(&s->pics[irq>>  3], irq&  7, level);
  		pic_update_irq(s);
+		trace_kvm_pic_set_irq(irq>>  3, irq&  7, s->pics[irq>>  3].elcr,
+				      s->pics[irq>>  3].imr, ret == 0);
 

It's better to send undecoded arguments (irq, s, ret) and do the shifting/masking/derefing in the TP_fast_assign. This is because argument preparation is always compiled inline and executed (so I understand; not sure) but TP_fast_assign is out-of-line and only executed if the tracepoint is enabled.

arch/x86/kvm/i8259.c int kvm_pic_set_irq(void *opaque, int irq, int level)

Quoted 12 lines
arch/x86/kvm/i8259.c +11 -0
+TRACE_EVENT(kvm_pic_set_irq,
+	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, int coalesced),
+	    TP_ARGS(chip, pin, elcr, imr, coalesced),
+
+	TP_STRUCT__entry(
+		__field(	__u8,		chip		)
+		__field(	__u8,		pin		)
+		__field(	__u8,		elcr		)
+		__field(	__u8,		imr		)
+		__field(	int,		coalesced	)
+	),

bool is slightly more descriptive.

Quoted 6 lines
arch/x86/kvm/i8259.c +5 -0
+
+	TP_fast_assign(
+		__entry->chip		= chip;
+		__entry->pin		= pin;
+		__entry->elcr		= elcr;

arch/x86/kvm/i8259.c

Quoted 10 lines
arch/x86/kvm/i8259.c +10 -0
+		__entry->imr		= imr;
+		__entry->coalesced	= coalesced;
+	),
+
+	TP_printk("chip=%u pin=%u (%s%s)%s",
+		  __entry->chip, __entry->pin,
+		  (__entry->elcr&  (1<<  __entry->pin)) ? "level":"edge",
+		  (__entry->imr&  (1<<  __entry->pin)) ? "|masked":"",
+		  __entry->coalesced ? " (coalesced)" : "")
+);

kvm style is not to use equals signs.

arch/x86/kvm/i8259.c

Quoted 9 lines
arch/x86/kvm/i8259.c +8 -0
+
+	TP_printk("dst=%x vec=%u (%s|%s|%s|%s|%s)",
+		  __entry->dest_id, (u8)__entry->icr_low,
+		  __print_symbolic((__entry->icr_low>>  8&  0x7),
+				   kvm_deliver_mode),
+		  (__entry->icr_low&  (1<<11)) ? "logical":"physical",
+		  (__entry->icr_low&  (1<<14)) ? "assert":"de-assert",
+		  (__entry->icr_low&  (1<<15)) ? "level":"edge",

Spaces around :.

arch/x86/kvm/i8259.c

Quoted 8 lines
arch/x86/kvm/i8259.c +7 -0
+	TP_STRUCT__entry(
+		__field(	__u32,		apicid		)
+		__field(	__u8,		dm		)
+		__field(	__u8,		tm		)
+		__field(	__u8,		vec		)
+		__field(	__u8,		coalesced	)
+	),

bool.

arch/x86/kvm/i8259.c

Quoted 8 lines
arch/x86/kvm/i8259.c +7 -0
+
+TRACE_EVENT(kvm_msi_set_irq,
+	    TP_PROTO(__u32 address, __u64 data),
+	    TP_ARGS(address, data),
+
+	TP_STRUCT__entry(
+		__field(	__u32,		address		)

Make this a u64 just in case.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Gleb Natapov

Add tracepoint in msi/ioapic/pic set_irq() functions, in IPI sending and in the point where IRQ is placed into apic's IRR.

arch/x86/kvm/i8259.c +1 -0
index 1d1bb75..e4bcbdd 100644
@@ -30,6 +30,7 @@
  #include "irq.h"
 
  #include<linux/kvm_host.h>
+#include "trace.h"
 
Quoted 15 lines

arch/x86/kvm/i8259.c int kvm_pic_set_irq(void *opaque, int irq, int level) · line 196

Quoted 9 lines
arch/x86/kvm/i8259.c +2 -0
  static void pic_lock(struct kvm_pic *s)
  	__acquires(&s->lock)
@@ -190,6 +191,8 @@ int kvm_pic_set_irq(void *opaque, int irq, int level)
  	if (irq>= 0&&  irq<  PIC_NUM_PINS) {
  		ret = pic_set_irq1(&s->pics[irq>>  3], irq&  7, level);
  		pic_update_irq(s);
+		trace_kvm_pic_set_irq(irq>>  3, irq&  7, s->pics[irq>>  3].elcr,
+				      s->pics[irq>>  3].imr, ret == 0);
 

It's better to send undecoded arguments (irq, s, ret) and do the shifting/masking/derefing in the TP_fast_assign. This is because argument preparation is always compiled inline and executed (so I understand; not sure) but TP_fast_assign is out-of-line and only executed if the tracepoint is enabled.

This will move knowledge how gsi is mapped to pic chips into tracing code. This will break if we will add emulation to some fantastic HW with number of pics different from 2.

--
Gleb.

#3 lore raw
Quoted 35 lines · Gleb Natapov
Quoted 17 lines · Avi Kivity
Quoted 15 lines · Gleb Natapov

Add tracepoint in msi/ioapic/pic set_irq() functions, in IPI sending and in the point where IRQ is placed into apic's IRR.

arch/x86/kvm/i8259.c +1 -0
index 1d1bb75..e4bcbdd 100644
@@ -30,6 +30,7 @@
   #include "irq.h"
 
   #include<linux/kvm_host.h>
+#include "trace.h"
 
Quoted 16 lines

arch/x86/kvm/i8259.c int kvm_pic_set_irq(void *opaque, int irq, int level) · line 197

Quoted 10 lines
arch/x86/kvm/i8259.c +2 -0
   static void pic_lock(struct kvm_pic *s)
   	__acquires(&s->lock)
@@ -190,6 +191,8 @@ int kvm_pic_set_irq(void *opaque, int irq, int level)
   	if (irq>= 0&&   irq<   PIC_NUM_PINS) {
   		ret = pic_set_irq1(&s->pics[irq>>   3], irq&   7, level);
   		pic_update_irq(s);
+		trace_kvm_pic_set_irq(irq>>   3, irq&   7, s->pics[irq>>   3].elcr,
+				      s->pics[irq>>   3].imr, ret == 0);
 
 

It's better to send undecoded arguments (irq, s, ret) and do the shifting/masking/derefing in the TP_fast_assign. This is because argument preparation is always compiled inline and executed (so I understand; not sure) but TP_fast_assign is out-of-line and only executed if the tracepoint is enabled.

Quoted 4 lines

This will move knowledge how gsi is mapped to pic chips into tracing code. This will break if we will add emulation to some fantastic HW with number of pics different from 2.

Right, that doesn't work out well in this case. Something to keep in mind in general.

(Could still be handled by defining inline functions or macros to do the decoding and using them in TP_fast_assign, but probably not worth it in this case)

Signature · 1 line
error compiling committee.c: too many arguments to function