From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 20 21:45:23 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 099DB106564A for ; Fri, 20 Aug 2010 21:45:23 +0000 (UTC) (envelope-from john.giacomoni@lineratesystems.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id C36408FC12 for ; Fri, 20 Aug 2010 21:45:22 +0000 (UTC) Received: by ywk9 with SMTP id 9so1734179ywk.13 for ; Fri, 20 Aug 2010 14:45:21 -0700 (PDT) Received: by 10.151.83.11 with SMTP id k11mr2687456ybl.116.1282338962070; Fri, 20 Aug 2010 14:16:02 -0700 (PDT) Received: from [10.126.1.124] (174-29-36-52.hlrn.qwest.net [174.29.36.52]) by mx.google.com with ESMTPS id v32sm693876yba.18.2010.08.20.14.16.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 20 Aug 2010 14:16:01 -0700 (PDT) From: John Giacomoni Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Fri, 20 Aug 2010 15:15:59 -0600 Message-Id: <5F142BAD-E8F5-46C4-9AF3-D5E7AEAD93A0@lineratesystems.com> To: freebsd-hackers@freebsd.org Mime-Version: 1.0 (Apple Message framework v1081) X-Mailer: Apple Mail (2.1081) X-Mailman-Approved-At: Fri, 20 Aug 2010 21:55:20 +0000 Subject: 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: Fri, 20 Aug 2010 21:45:23 -0000 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). 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