From owner-p4-projects@FreeBSD.ORG Thu Jan 29 07:24:49 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5FB3016A4D0; Thu, 29 Jan 2004 07:24:49 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 345EC16A4CE for ; Thu, 29 Jan 2004 07:24:49 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29A7243D41 for ; Thu, 29 Jan 2004 07:24:42 -0800 (PST) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i0TFOf0B083157 for ; Thu, 29 Jan 2004 07:24:41 -0800 (PST) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i0TFOfCu083148 for perforce@freebsd.org; Thu, 29 Jan 2004 07:24:41 -0800 (PST) (envelope-from jhb@freebsd.org) Date: Thu, 29 Jan 2004 07:24:41 -0800 (PST) Message-Id: <200401291524.i0TFOfCu083148@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Subject: PERFORCE change 46130 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2004 15:24:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=46130 Change 46130 by jhb@jhb_slimer on 2004/01/29 07:23:40 Implement simple throttling for interrupt storms. Affected files ... .. //depot/projects/smpng/sys/kern/kern_intr.c#40 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_intr.c#40 (text+ko) ==== @@ -72,6 +72,11 @@ static void ithread_loop(void *); static void start_softintr(void *); +static int intr_storm_threshold = 500; +TUNABLE_INT("hw.intr_storm_threshold", &intr_storm_threshold); +SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RW, &intr_storm_threshold, 0, + "Number of consecutive interrupts before interrupt storm protection is enabled."); + u_char ithread_priority(enum intr_type flags) { @@ -488,12 +493,15 @@ struct intrhand *ih; /* and our interrupt handler chain */ struct thread *td; struct proc *p; + int count, warned; 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__)); + count = 0; + warned = 0; /* * As long as we have interrupts outstanding, go through the @@ -523,6 +531,22 @@ * another pass. */ atomic_store_rel_int(&ithd->it_need, 0); + + /* + * If we detect an interrupt storm, pause with the source masked + * for 1/10th of a second. + */ + if (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, "throttle", hz / 10); + count = 0; + } else + count++; restart: TAILQ_FOREACH(ih, &ithd->it_handlers, ih_next) { if (ithd->it_flags & IT_SOFT && !ih->ih_need) @@ -562,6 +586,7 @@ mtx_lock_spin(&sched_lock); if (!ithd->it_need) { TD_SET_IWAIT(td); + count = 0; CTR2(KTR_INTR, "%s: pid %d: done", __func__, p->p_pid); mi_switch(SW_VOL); CTR2(KTR_INTR, "%s: pid %d: resumed", __func__, p->p_pid);