Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Oct 2004 12:37:37 +0900
From:      Shunsuke SHINOMIYA <shino@fornext.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        obrien@FreeBSD.org
Subject:   Re[2]: disabling interrupt storm protection
Message-ID:  <20041030105024.360A.SHINO@fornext.org>
In-Reply-To: <200410281111.24398.jhb@FreeBSD.org>
References:  <20041028165604.DCF8.SHINO@fornext.org> <200410281111.24398.jhb@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]

 Thank you John,

 I wrote a patch(which is attached to this mail) so that the problem
 doesn't occur in my environment.

 This patch changes the meaning of `storm'.
 But, I think use of the parameter(hw_intr_threshold) to control the
detector in this method is clearer than the present method, and it
needs no DELAY(1).

 In the detector to which this patch is applied and compiled with
 -DHACK2 flag, `storm' is the situation that the number of generated
 interrupts per unit time(1/hz) is larger than threshold.

 If kern_intr.c is compiled with -DHACK2 -DHACK3 flags, it works as
 interrupt rate limiter.
 
 What do you think about this method?

-- 
Shunsuke SHINOMIYA <shino@fornext.org>

[-- Attachment #2 --]
--- /home/shino/work/freebsd/src/sys/kern/kern_intr.c	Thu Sep  9 19:03:19 2004
+++ /home/shino/work/packetmerge/sys/kern/kern_intr.c	Sat Oct 30 11:53:59 2004
@@ -485,14 +485,23 @@ ithread_loop(void *arg)
 	struct intrhand *ih;		/* and our interrupt handler chain */
 	struct thread *td;
 	struct proc *p;
+#ifndef HACK2
 	int count, warming, warned;
+#else
+	int count, curr_ticks, 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__));
+#ifndef HACK2
 	warming = 10 * intr_storm_threshold;
+#else
+	count = 0;
+	curr_ticks = ticks;
+#endif
 	warned = 0;
 
 	/*
@@ -514,7 +523,9 @@ ithread_loop(void *arg)
 
 		CTR4(KTR_INTR, "%s: pid %d: (%s) need=%d", __func__,
 		     p->p_pid, p->p_comm, ithd->it_need);
+#ifndef HACK2
 		count = 0;
+#endif
 		while (ithd->it_need) {
 			/*
 			 * Service interrupts.  If another interrupt
@@ -548,6 +559,7 @@ restart:
 				if ((ih->ih_flags & IH_MPSAFE) == 0)
 					mtx_unlock(&Giant);
 			}
+#ifndef HACK2
 			if (ithd->it_enable != NULL) {
 				ithd->it_enable(ithd->it_vector);
 
@@ -567,6 +579,16 @@ restart:
 				}
 			}
 
+#else
+			if(intr_storm_threshold <= 0)
+				goto enable_intr;
+
+			if(curr_ticks != ticks) {
+				count = 0;
+				curr_ticks = ticks;
+				goto enable_intr;
+			}
+#endif /* HACK2 */
 			/*
 			 * If we detect an interrupt storm, sleep until
 			 * the next hardclock tick.  We sleep at the
@@ -595,9 +617,21 @@ restart:
 				 * away unless the interrupt repeats
 				 * less often the hardclock interrupt.
 				 */
+#ifndef HACK2
 				count = INT_MAX - 1;
 			}
+#else
+#ifndef HACK3
+				curr_ticks = ticks;
+#endif /* HACK3 */
+			} else
+#endif /* HACK2 */
 			count++;
+#ifdef HACK2
+enable_intr:
+			if (ithd->it_enable != NULL)
+				ithd->it_enable(ithd->it_vector);
+#endif /* HACK2 */
 		}
 		WITNESS_WARN(WARN_PANIC, NULL, "suspending ithread");
 		mtx_assert(&Giant, MA_NOTOWNED);
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041030105024.360A.SHINO>