From owner-freebsd-arch@FreeBSD.ORG Mon Aug 30 15:49:27 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 03DB416A4CE for ; Mon, 30 Aug 2004 15:49:27 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8831C43D2F for ; Mon, 30 Aug 2004 15:49:26 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from [192.168.0.12] (g4.samsco.home [192.168.0.12]) (authenticated bits=0) by pooker.samsco.org (8.12.11/8.12.10) with ESMTP id i7UFmvoD066507; Mon, 30 Aug 2004 09:48:57 -0600 (MDT) (envelope-from scottl@freebsd.org) Message-ID: <41334C3B.4070101@freebsd.org> Date: Mon, 30 Aug 2004 09:48:11 -0600 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040514 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sam References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=3.8 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on pooker.samsco.org cc: freebsd-arch@freebsd.org Subject: Re: splxxx level? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2004 15:49:27 -0000 Sam wrote: > Hello - > > I'm almost to testing on my AoE driver for 4.x and have > a question about interrupt priority levels. > > There are currently three entry points into the driver: > > a) strategy routine > b) network frame reception routine > c) timer rexmit routine > > Any of the three can diddle with the device structure > and thusly I need to ensure they're not running simultaneously. > For example, the network reception can cause a buf to be completed > and the rexmit timer can cause a buf to be failed. > > So, what kind of contexts are the callout, strategy, and > network soft interrupt called in? Which splxxx will give > one of them exclusive access to whatever they need? > > Just as a reality check -- I am thinking about this correct, right? > > Cheers, > > Sam > With 4.x, only one CPU can be in the kernel at a time. You won't have to worry about multiple processes trying to get into strategy at the same time and whatnot. However, you can be preempted by your interrupt handler or by a timeout or by a software interrupt like the netisr. I don't remember if your driver is for a specific piece of hardware or if it's a generic layer that sits in between the network interface and the block layer. If it's for dedicated hardware then you'll need to define a interrupt type in bus_setup_intr() and use that type for the spl (i.e. INTR_TYPE_NET translates to splnet(), INTR_TYPE_BIO translates to splbio(), etc). The safe way to go is to protect all of your critical code sections with the appropriate spl level regardless. spls are very cheap and can be set/reset from an interrupt context so there is little penalty in using them liberally at first and then narrowing them down later. Just make sure that you don't leak an spl references, and don't hold an spl for so long that it creates priority inversions. Since the only interrupts and timeouts that you'll likely be dealing with are network related, splnet() is probably the right one to use. Scott