Re: disabling interrupt storm protection

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 27 Oct 2004 13:52:04 -0400
On Friday 22 October 2004 04:26 am, Shunsuke SHINOMIYA wrote:
> > Hi,
> > has there been any ways to disable interrupt storm protection from
> > sys/kern/kern_intr.c:1.109?
>
>  Don't try sysctl hw.intr_storm_threshold=0. It mask all interrupt
>  sources.

Bah, that's supposed to work but I guess bde's enhancements broke it.

Can you try this patch:

--- //depot/vendor/freebsd/src/sys/kern/kern_intr.c	2004/09/05 02:10:52
+++ //depot/projects/smpng/sys/kern/kern_intr.c	2004/10/27 17:41:06
_at__at_ -485,14 +485,22 _at__at_
 	struct intrhand *ih;		/* and our interrupt handler chain */
 	struct thread *td;
 	struct proc *p;
+#ifdef HACK
 	int count, warming, warned;
+#else
+	int count, warned;
+#endif
 	
 	td = curthread;
 	p = td->td_proc;
 	ithd = (struct ithd *)arg;	/* point to myself */
 	KASSERT(ithd->it_td == td && td->td_ithd == ithd,
 	    ("%s: ithread and proc linkage out of sync", __func__));
+#ifdef HACK
 	warming = 10 * intr_storm_threshold;
+#else
+	count = 0;
+#endif
 	warned = 0;
 
 	/*
_at__at_ -514,7 +522,9 _at__at_
 
 		CTR4(KTR_INTR, "%s: pid %d: (%s) need=%d", __func__,
 		     p->p_pid, p->p_comm, ithd->it_need);
+#ifdef HACK
 		count = 0;
+#endif
 		while (ithd->it_need) {
 			/*
 			 * Service interrupts.  If another interrupt
_at__at_ -548,9 +558,29 _at__at_
 				if ((ih->ih_flags & IH_MPSAFE) == 0)
 					mtx_unlock(&Giant);
 			}
+
+#ifndef HACK
+			/*
+			 * If we detect an interrupt storm, pause with the
+			 * source masked until the next hardclock tick.
+			 */
+			if (intr_storm_threshold != 0 &&
+			    count >= intr_storm_threshold) {
+				if (!warned) {
+					printf(
+	"Interrupt storm detected on \"%s\"; throttling interrupt source\n",
+					    p->p_comm);
+					warned = 1;
+				}
+				tsleep(&count, td->td_priority, "istorm", 1);
+				count = 0;
+			} else
+				count++;
+#endif
+
 			if (ithd->it_enable != NULL) {
 				ithd->it_enable(ithd->it_vector);
-
+#ifdef HACK
 				/*
 				 * Storm detection needs a delay here
 				 * to see slightly delayed interrupts
_at__at_ -565,8 +595,10 _at__at_
 					DELAY(1);
 					--warming;
 				}
+#endif
 			}
 
+#ifdef HACK
 			/*
 			 * If we detect an interrupt storm, sleep until
 			 * the next hardclock tick.  We sleep at the
_at__at_ -574,7 +606,8 _at__at_
 			 * to ensure that we see slightly delayed
 			 * interrupts.
 			 */
-			if (count >= intr_storm_threshold) {
+			if (intr_storm_threshold != 0 &&
+			    count >= intr_storm_threshold) {
 				if (!warned) {
 					printf(
 	"Interrupt storm detected on \"%s\"; throttling interrupt source\n",
_at__at_ -598,6 +631,7 _at__at_
 				count = INT_MAX - 1;
 			}
 			count++;
+#endif
 		}
 		WITNESS_WARN(WARN_PANIC, NULL, "suspending ithread");
 		mtx_assert(&Giant, MA_NOTOWNED);
_at__at_ -610,6 +644,9 _at__at_
 		mtx_lock_spin(&sched_lock);
 		if (!ithd->it_need) {
 			TD_SET_IWAIT(td);
+#ifndef HACK
+			count = 0;
+#endif
 			CTR2(KTR_INTR, "%s: pid %d: done", __func__, p->p_pid);
 			mi_switch(SW_VOL, NULL);
 			CTR2(KTR_INTR, "%s: pid %d: resumed", __func__, p->p_pid);

First, can you test that your system works with the default threshold, and 
second, can you test that setting the threshold to zero disables the storm 
detection?

-- 
John Baldwin <jhb_at_FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
Received on Wed Oct 27 2004 - 15:52:39 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:19 UTC