Skip to contentSkip to conversation

spurious interrupt monitoring patch

PATCH Jan Beulich 1 participant 1 message Apr 6, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

As per Ian's request, I'm providing below patch to possibly help identify a problem we are seeing on basically all 64-bit systems where smaller or larger amounts of unhandled interrupts (including cases on lines where no activity is expected all, based on the behavior with a native kernel on the same system). Jan

arch/i386/kernel/irq-xen.c +14 -4
Index: head-2006-04-05/arch/i386/kernel/irq-xen.c
===================================================================
@@ -224,9 +224,17 @@ int show_interrupts(struct seq_file *p, 
 	}
 
 	if (i < NR_IRQS) {
+		unsigned any_count = 0;
+
 		spin_lock_irqsave(&irq_desc[i].lock, flags);
+#ifndef CONFIG_SMP
+		any_count = kstat_irqs(i);
+#else
+		for_each_online_cpu(j)
+			any_count |= kstat_cpu(j).irqs[i];
+#endif
 		action = irq_desc[i].action;
-		if (!action)
+		if (!action && !any_count)
 			goto skip;
 		seq_printf(p, "%3d: ",i);
 #ifndef CONFIG_SMP
@@ -236,10 +244,12 @@ int show_interrupts(struct seq_file *p, 
 			seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
 #endif
 		seq_printf(p, " %14s", irq_desc[i].handler->typename);
-		seq_printf(p, "  %s", action->name);
 
-		for (action=action->next; action; action = action->next)
-			seq_printf(p, ", %s", action->name);
+		if (action) {
+			seq_printf(p, "  %s", action->name);
+			while ((action = action->next) != NULL)
+				seq_printf(p, ", %s", action->name);
+		}
 
 		seq_putc(p, '\n');
 skip:
arch/x86_64/kernel/irq-xen.c +14 -4
Index: head-2006-04-05/arch/x86_64/kernel/irq-xen.c
===================================================================
@@ -45,9 +45,17 @@ int show_interrupts(struct seq_file *p, 
 	}
 
 	if (i < NR_IRQS) {
+		unsigned any_count = 0;
+
 		spin_lock_irqsave(&irq_desc[i].lock, flags);
+#ifndef CONFIG_SMP
+		any_count = kstat_irqs(i);
+#else
+		for (j=0; j<NR_CPUS; j++)
+			any_count |= kstat_cpu(j).irqs[i];
+#endif
 		action = irq_desc[i].action;
-		if (!action) 
+		if (!action && !any_count)
 			goto skip;
 		seq_printf(p, "%3d: ",i);
 #ifndef CONFIG_SMP
@@ -60,9 +68,11 @@ int show_interrupts(struct seq_file *p, 
 #endif
 		seq_printf(p, " %14s", irq_desc[i].handler->typename);
 
-		seq_printf(p, "  %s", action->name);
-		for (action=action->next; action; action = action->next)
-			seq_printf(p, ", %s", action->name);
+		if (action) {
+			seq_printf(p, "  %s", action->name);
+			while ((action = action->next) != NULL)
+				seq_printf(p, ", %s", action->name);
+		}
 		seq_putc(p, '\n');
 skip:
 		spin_unlock_irqrestore(&irq_desc[i].lock, flags);
include/linux/irq.h +3 -0
Index: head-2006-04-05/include/linux/irq.h
===================================================================
@@ -80,6 +80,9 @@ typedef struct irq_desc {
 #if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
 	unsigned int move_irq;		/* Flag need to re-target intr dest*/
 #endif
+#ifdef CONFIG_XEN
+	unsigned int unhandled_threshold;
+#endif
 } ____cacheline_aligned irq_desc_t;
 
 extern irq_desc_t irq_desc [NR_IRQS];
kernel/irq/spurious.c +22 -0
Index: head-2006-04-05/kernel/irq/spurious.c
===================================================================
@@ -125,7 +125,11 @@ __report_bad_irq(unsigned int irq, irq_d
 
 static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
 {
+#ifndef CONFIG_XEN
 	static int count = 100;
+#else
+	static int count = NR_IRQS * 50;
+#endif
 
 	if (count > 0) {
 		count--;
@@ -133,6 +137,10 @@ static void report_bad_irq(unsigned int 
 	}
 }
 
+#ifdef CONFIG_XEN
+#include <xen/evtchn.h>
+#endif
+
 void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret,
 			struct pt_regs *regs)
 {
@@ -140,6 +148,20 @@ void note_interrupt(unsigned int irq, ir
 		desc->irqs_unhandled++;
 		if (action_ret != IRQ_NONE)
 			report_bad_irq(irq, desc, action_ret);
+#ifdef CONFIG_XEN
+		else if (desc->irqs_unhandled > desc->unhandled_threshold) {
+unsigned cpu = smp_processor_id();
+const struct evtchn_irq_status*status = &per_cpu(evtchn_irq_status, cpu);
+
+printk("On CPU#%u:\n", cpu);
+do {
+ printk("IRQ%u: l1=%08lX(%u) l2=%08lX(%u)\n", irq, status->l1, status->l1i, status->l2, status->l2i);
+ status = status->link;
+} while(status);
+			desc->unhandled_threshold |= desc->irqs_unhandled;
+			report_bad_irq(irq, desc, action_ret);
+		}
+#endif
 	}
 
 	if (unlikely(irqfixup)) {
drivers/xen/core/evtchn.c +56 -0

97 lines not on this page · raw message

include/xen/evtchn.h +10 -0
Index: head-2006-04-05/include/xen/evtchn.h
===================================================================
@@ -113,6 +113,16 @@ static inline void notify_remote_via_evt
  */
 extern void notify_remote_via_irq(int irq);
 
+struct evtchn_irq_status {
+	struct evtchn_irq_status *link;
+	unsigned long l1, l2;
+	unsigned int l1i, l2i;
+};
+DECLARE_PER_CPU(struct evtchn_irq_status, evtchn_irq_status);
+
+struct evtchn_op;
+extern void dump_evtchn_op(const struct evtchn_op*, int);
+
 #endif /* __ASM_EVTCHN_H__ */
 
 /*
include/asm-x86_64/mach-xen/asm/hypercall.h +7 -1
Index: head-2006-04-05/include/asm-x86_64/mach-xen/asm/hypercall.h
===================================================================
@@ -241,11 +241,17 @@ HYPERVISOR_update_va_mapping(
 	return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
 }
 
+struct evtchn_op;
+extern void dump_evtchn_op(const struct evtchn_op*, int);
+
 static inline int
 HYPERVISOR_event_channel_op(
 	void *op)
 {
-	return _hypercall1(int, event_channel_op, op);
+	int rc = _hypercall1(int, event_channel_op, op);
+
+	dump_evtchn_op(op, rc);
+	return rc;
 }
 
 static inline int

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel