From owner-freebsd-net@FreeBSD.ORG Fri Mar 16 14:13:54 2007 Return-Path: X-Original-To: freebsd-net@FreeBSD.org Delivered-To: freebsd-net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E152816A402; Fri, 16 Mar 2007 14:13:54 +0000 (UTC) (envelope-from bohra@nec-labs.com) Received: from mail.nec-labs.com (mail.nec-labs.com [138.15.200.209]) by mx1.freebsd.org (Postfix) with ESMTP id A587913C46E; Fri, 16 Mar 2007 14:13:54 +0000 (UTC) (envelope-from bohra@nec-labs.com) Received: from mail.nec-labs.com (localhost.localdomain [127.0.0.1]) by mail.nec-labs.com (8.13.6/8.13.6) with ESMTP id l2GDmS0K032016; Fri, 16 Mar 2007 09:48:28 -0400 Received: from mailer.nec-labs.com (mailer.nec-labs.com [138.15.108.3]) by mail.nec-labs.com (8.13.6/8.13.6) with ESMTP id l2GDmSa7032009; Fri, 16 Mar 2007 09:48:28 -0400 Received: from [138.15.109.80] ([138.15.109.80] unverified) by mailer.nec-labs.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 16 Mar 2007 09:48:28 -0400 Message-ID: <45FAA00F.4070208@nec-labs.com> Date: Fri, 16 Mar 2007 09:47:59 -0400 From: Aniruddha Bohra User-Agent: Thunderbird 1.5.0.9 (X11/20070217) MIME-Version: 1.0 To: Robert Watson References: <45FA98DD.3080205@cs.rutgers.edu> <20070316141836.J60288@fledge.watson.org> In-Reply-To: <20070316141836.J60288@fledge.watson.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Mar 2007 13:48:28.0382 (UTC) FILETIME=[C6C2A7E0:01C767D1] Cc: freebsd-net@FreeBSD.org Subject: Re: ether_input question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2007 14:13:55 -0000 Robert Watson wrote: > On Fri, 16 Mar 2007, Aniruddha Bohra wrote: >> My question is : Does ether_input() assume it is the only thread >> executing the code? If it is the case, what is the reason for >> dropping the lock in the DEVICE_POLLING case? > > I can't speak to the details of the above, but can speak generally on > the issue of the link layer input path and locking. There is no > assumption that the caller will provide serialization, and fully > concurrent input from multiple threads is supported. The reason the > drivers drop their locks is that the network stack frequently holds > locks over calls to driver output routines. As a result, driver locks > tend to follow network stack locks in the lock order--at least, for > drivers that have a single lock covering both send and receive paths > (quite common). As a result, the driver must drop the driver lock > before calling into the stack to avoid a lock order reversal. Thanks Robert, So, if I have a queue shared between ether_input() and another thread, I need to ensure mutual exclusion. In such scenarios, should spinlocks or default mutexes be used? The driver locks themselves are usually MTX_DEF, whereas in netgraph for example, (the scenario above), a spinlock is used. Is there a rule of thumb, for example, never use blocking locks in the network interrupt path? Thanks Aniruddha