diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -300,6 +300,8 @@ ie->ie_flags = flags; ie->ie_irq = irq; ie->ie_cpu = NOCPU; + ie->ie_stray = 0; + ie->ie_intrcnt = 0; CK_SLIST_INIT(&ie->ie_handlers); mtx_init(&ie->ie_lock, "intr event", NULL, MTX_DEF); @@ -1372,9 +1374,18 @@ intr_prof_stack_use(td, frame); #endif - /* An interrupt with no event or handlers is a stray interrupt. */ - if (ie == NULL || CK_SLIST_EMPTY(&ie->ie_handlers)) + /* An interrupt with no event is a stray interrupt. */ + if (ie == NULL) + return (EINVAL); + + /* Increment the interrupt counter. */ + atomic_add_long(&ie->ie_intrcnt, 1); + + /* An interrupt with no handlers is a stray interrupt. */ + if (CK_SLIST_EMPTY(&ie->ie_handlers)) { + atomic_add_long(&ie->ie_stray, 1); return (EINVAL); + } /* * Execute fast interrupt handlers directly. @@ -1475,8 +1486,10 @@ td->td_intr_nesting_level--; #ifdef notyet /* The interrupt is not aknowledged by any filter and has no ithread. */ - if (!thread && !filter) + if (!thread && !filter) { + atomic_add_long(&ie->ie_stray, 1); return (EINVAL); + } #endif return (0); } diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -127,6 +127,8 @@ int ie_cpu; /* CPU this event is bound to. */ volatile int ie_phase; /* Switched to establish a barrier. */ volatile int ie_active[2]; /* Filters in ISR context. */ + u_long ie_stray; /* Stray interrupt counter */ + u_long ie_intrcnt; /* Interrupt counter */ }; /* Interrupt event flags kept in ie_flags. */