Skip to contentSkip to conversation

x86/irq: Add additional unhandled IRQ debug information

PATCH Superseded Prarit Bhargava 2 participants 2 messages Dec 6, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/irq: Add additional unhandled IRQ debug information

The current unhandled IRQ warning doesn't output enough information on x86 to determine which device issued an interrupt. For example,

irq 16: nobody cared (try booting with the "irqpoll" option)

CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.9.0-rc6+ #19
Hardware name: Hewlett-Packard HP Z820 Workstation/158B, BIOS J63 v03.90 06/01/2016
 ffff88041f803eb0 ffffffff81337a95 ffff880418607200 ffff88041860729c
 ffff88041f803ed8 ffffffff810db845 ffff880418607200 0000000000000000
 0000000000000010 ffff88041f803f10 ffffffff810dbb9f ffff880418607200
Call Trace:
 <IRQ>  [<ffffffff81337a95>] dump_stack+0x63/0x8e
 [<ffffffff810db845>] __report_bad_irq+0x35/0xd0
 [<ffffffff810dbb9f>] note_interrupt+0x20f/0x260
 [<ffffffff810d8f05>] handle_irq_event_percpu+0x45/0x60
 [<ffffffff810d8f4c>] handle_irq_event+0x2c/0x50
 [<ffffffff810dc8ca>] handle_fasteoi_irq+0x8a/0x150
 [<ffffffff8102ee0b>] handle_irq+0xab/0x130
 [<ffffffff8109de6a>] ? atomic_notifier_call_chain+0x1a/0x20
 [<ffffffff8103631d>] ? __exit_idle+0x2d/0x30
 [<ffffffff81715bad>] do_IRQ+0x4d/0xd0
 [<ffffffff81713c02>] common_interrupt+0x82/0x82
 <EOI>  [<ffffffff815e3931>] ? cpuidle_enter_state+0xc1/0x280
 [<ffffffff815e3924>] ? cpuidle_enter_state+0xb4/0x280
 [<ffffffff815e3b27>] cpuidle_enter+0x17/0x20
 [<ffffffff810c1813>] call_cpuidle+0x23/0x40
 [<ffffffff810c1a79>] cpu_startup_entry+0x149/0x240
 [<ffffffff81705fe7>] rest_init+0x77/0x80
 [<ffffffff81d8a147>] start_kernel+0x495/0x4a2
 [<ffffffff81d89aa0>] ? set_init_arg+0x55/0x55
 [<ffffffff81d89120>] ? early_idt_handler_array+0x120/0x120
 [<ffffffff81d895d6>] x86_64_start_reservations+0x2a/0x2c
 [<ffffffff81d89715>] x86_64_start_kernel+0x13d/0x14c

handlers:
[<ffffffff8155b050>] usb_hcd_irq
Disabling IRQ #16

The unhandled interrupt is issued against IRQ 16, however, in many cases the handlers listed do not have anything to do with the device that has issued the interrupt.

This patch adds weak function arch_irq_debug(), and adds an x86 specific definition. The x86 version dumps the following information: the status of the IO APIC pin line associated with the IRQ, the state of the CPU's LAPIC, and the PCI devices which have their interrupt set.

This information is output:

Additional x86 information on IRQ #16 ...
IRQ16 maps to APIC0 PIN16 : pin10, enabled , level, low , V(10), IRR(1), S(1), remapped, I(98013), Z(0) This CPU APIC ID is 0, and cpu id is 0.
CPU 0 LAPIC IRR dump:
APIC IRR 7 (IRQs 255 to 224) = 0x20008000 [ 239 253 ]
APIC IRR 6 (IRQs 223 to 192) = 0x0
APIC IRR 5 (IRQs 191 to 160) = 0x0
APIC IRR 4 (IRQs 159 to 128) = 0x0
APIC IRR 3 (IRQs 127 to 96) = 0x0
APIC IRR 2 (IRQs 95 to 64) = 0x0
APIC IRR 1 (IRQs 63 to 32) = 0x0
APIC IRR 0 (IRQs 31 to 0) = 0x0
Disabling IRQ #16
PCI devices with INTERRUPT STATUS set (bit 3 of PCI_STATUS register):
possible unhandled irq source 0000:00:16.0: pin = 1
possible unhandled irq source 0000:05:00.0: pin = 1

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Rui Wang <[email protected]>
Cc Paul Gortmaker <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Aaron Lu <[email protected]>
---
 arch/x86/include/asm/io_apic.h |    2 ++
 arch/x86/kernel/apic/io_apic.c |   70 ++++++++++++++++++++++++++--------------
 arch/x86/kernel/irq.c          |   66 +++++++++++++++++++++++++++++++++++++
 kernel/irq/spurious.c          |    9 ++++++
 4 files changed, 123 insertions(+), 24 deletions(-)
arch/x86/include/asm/io_apic.h +2 -0
index 6cbf2cfb3f8a..fecc301f8be2 100644
@@ -195,6 +195,7 @@ static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
 extern void setup_ioapic_dest(void);
 extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
 extern void print_IO_APICs(void);
+extern void print_IRQ_to_pin_mapping(unsigned int irq);
 #else  /* !CONFIG_X86_IO_APIC */
 
 #define IO_APIC_IRQ(x)		0
@@ -203,6 +204,7 @@ static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
 static inline void ioapic_insert_resources(void) { }
 static inline int arch_early_ioapic_init(void) { return 0; }
 static inline void print_IO_APICs(void) {}
+static inline print_IRQ_to_pin_mapping(unsigned int irq) {}
 #define gsi_top (NR_IRQS_LEGACY)
 static inline int mp_find_ioapic(u32 gsi) { return 0; }
 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
arch/x86/kernel/apic/io_apic.c +46 -24

93 lines not on this page · raw message

arch/x86/kernel/irq.c +66 -0

75 lines not on this page · raw message

kernel/irq/spurious.c +9 -0
index 5707f97a3e6a..fac67b799974 100644
@@ -180,6 +180,14 @@ static inline int bad_action_ret(irqreturn_t action_ret)
 	return 1;
 }
 
+void __weak arch_irq_debug(unsigned int irq)
+{
+	/*
+	 * This weak function provides a method to dump arch-specific
+	 * data to further debug unhandled IRQs or IRQ storms.
+	 */
+}
+
 /*
  * If 99,900 of the previous 100,000 interrupts have not been handled
  * then assume that the IRQ is stuck in some manner. Drop a diagnostic
@@ -218,6 +226,7 @@ static void __report_bad_irq(struct irq_desc *desc, irqreturn_t action_ret)
 					action->thread_fn, action->thread_fn);
 		printk(KERN_CONT "\n");
 	}
+	arch_irq_debug(irq);
 	raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
Signature · 1 line
1.7.9.3
#1 lore raw
url: https://github.com/0day-ci/linux/commits/Prarit-Bhargava/x86-irq-Add-additional-unhandled-IRQ-debug-information/20161207-022400 config: i386-tinyconfig (attached as .config) compiler: gcc-6…

Hi Prarit,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.9-rc8 next-20161206]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Prarit-Bhargava/x86-irq-Add-additional-unhandled-IRQ-debug-information/20161207-022400
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

In file included from arch/x86/kernel/irq.c:16:0:

>> arch/x86/include/asm/io_apic.h:207:15: warning: return type defaults to 'int' [-Wreturn-type]
    static inline print_IRQ_to_pin_mapping(unsigned int irq) {}
                  ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/kobject.h:29:0,
                    from include/linux/device.h:17,
                    from include/linux/node.h:17,
                    from include/linux/cpu.h:16,
                    from arch/x86/kernel/irq.c:4:
   arch/x86/kernel/irq.c: In function 'arch_irq_debug':
>> arch/x86/kernel/irq.c:584:13: error: 'x86_unhandled_irq_work' undeclared (first use in this function)
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
                ^
   include/linux/workqueue.h:216:16: note: in definition of macro '__INIT_WORK'
      __init_work((_work), _onstack);    \
                   ^~~~~
   arch/x86/kernel/irq.c:584:2: note: in expansion of macro 'INIT_WORK'
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
     ^~~~~~~~~
   arch/x86/kernel/irq.c:584:13: note: each undeclared identifier is reported only once for each function it appears in
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
                ^
   include/linux/workqueue.h:216:16: note: in definition of macro '__INIT_WORK'
      __init_work((_work), _onstack);    \
                   ^~~~~
   arch/x86/kernel/irq.c:584:2: note: in expansion of macro 'INIT_WORK'
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
     ^~~~~~~~~
>> arch/x86/kernel/irq.c:584:37: error: 'x86_unhandled_irq_work_fn' undeclared (first use in this function)
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
                                        ^
   include/linux/workqueue.h:219:20: note: in definition of macro '__INIT_WORK'
      (_work)->func = (_func);    \
                       ^~~~~
   arch/x86/kernel/irq.c:584:2: note: in expansion of macro 'INIT_WORK'
     INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);
     ^~~~~~~~~
   arch/x86/kernel/irq.c:579:6: warning: unused variable 'reg' [-Wunused-variable]
     u32 reg;
         ^~~
   arch/x86/kernel/irq.c:578:11: warning: unused variable 'bit' [-Wunused-variable]
     int irr, bit;
              ^~~
   arch/x86/kernel/irq.c:578:6: warning: unused variable 'irr' [-Wunused-variable]
     int irr, bit;
         ^~~
--
   In file included from arch/x86/kernel/setup.c:85:0:
>> arch/x86/include/asm/io_apic.h:207:15: warning: return type defaults to 'int' [-Wreturn-type]
    static inline print_IRQ_to_pin_mapping(unsigned int irq) {}
                  ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/x86_unhandled_irq_work +584 arch/x86/kernel/irq.c

578 int irr, bit;
579 u32 reg;
580
581 pr_emerg("Additional x86 information on IRQ #%d ...\n", irq);
582
583 /* PCI information cannot be dumped in interrupt context */

 > 584		INIT_WORK(&x86_unhandled_irq_work, x86_unhandled_irq_work_fn);

585 schedule_work_on(smp_processor_id(), &x86_unhandled_irq_work);
586
587 #ifdef CONFIG_X86_IO_APIC

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation