From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 21 00:30:15 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5317510656AE for ; Sat, 21 Aug 2010 00:30:15 +0000 (UTC) (envelope-from julian@elischer.org) Received: from out-0.mx.aerioconnect.net (out-0-37.mx.aerioconnect.net [216.240.47.97]) by mx1.freebsd.org (Postfix) with ESMTP id 351A08FC15 for ; Sat, 21 Aug 2010 00:30:14 +0000 (UTC) Received: from idiom.com (postfix@mx0.idiom.com [216.240.32.160]) by out-0.mx.aerioconnect.net (8.13.8/8.13.8) with ESMTP id o7L06e53020065; Fri, 20 Aug 2010 17:06:40 -0700 X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id A57742D6011; Fri, 20 Aug 2010 17:06:39 -0700 (PDT) Message-ID: <4C6F18A1.7090705@elischer.org> Date: Fri, 20 Aug 2010 17:06:57 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 MIME-Version: 1.0 To: John Giacomoni References: <5F142BAD-E8F5-46C4-9AF3-D5E7AEAD93A0@lineratesystems.com> In-Reply-To: <5F142BAD-E8F5-46C4-9AF3-D5E7AEAD93A0@lineratesystems.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 216.240.47.51 Cc: freebsd-hackers@freebsd.org Subject: Re: use of rwlocks safe in network stack? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Aug 2010 00:30:15 -0000 On 8/20/10 2:15 PM, John Giacomoni wrote: > Can someone help me understand how it is safe to process network packets from within a driver's interrupt context? > It looks to me like the network drivers (bce in particular) violate the rules laid out in locking (9). The trick is that most of the 'interrupt' handlers in the system are not really interrupt handlers directly, but rather threads that are kicked into life when a 'stub' interrupt handler kicks them. The stub is system supplied unless the driver specifically supplies one (called a "FAST" interrupt handler) in which case THAT is a real interrupt handler and must only use spinlocks. I hope that helps.. I'm sure there is a man page for it in chapter 9 somewhere. (looks) ah yes man ithread should be a good start. > > In FreeBSD 7.3 the bce driver's RX interrupt can call up into the network stack (bce_intr -> bce_rx_intr -> if_input) which will grab INP_INFO_WLOCK (rw_wlock) when it hits the TCP layer. > > pfslowtimo also acquires INP_INFO_LOCK. > > Is this safe? locking (9) says that acquiring a rw_wlock is not allowed in interrupt context and rw_wlock can "sleep" via mi_switch in the turnstile code. > > Is this a locking order type rule? and if so, is the rule being ignored because network stack is guaranteed to return in a finite amount of time? Or is the bce interrupt a different type of interrupt than referred to in locking (9) ? > > Thanks, > > John Giacomoni > > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"