From owner-freebsd-drivers@FreeBSD.ORG Mon May 19 15:01:00 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6FE61065676 for ; Mon, 19 May 2008 15:01:00 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id C05A78FC17 for ; Mon, 19 May 2008 15:01:00 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (unknown [208.65.91.234]) by elvis.mu.org (Postfix) with ESMTP id 491931A4D82; Mon, 19 May 2008 08:01:00 -0700 (PDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Mon, 19 May 2008 09:15:00 -0400 User-Agent: KMail/1.9.7 References: <17277776.post@talk.nabble.com> In-Reply-To: <17277776.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805190915.00902.jhb@freebsd.org> Cc: n4ti1us Subject: Re: Spin locks and software IRQs. X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 May 2008 15:01:00 -0000 On Friday 16 May 2008 11:37:46 am n4ti1us wrote: > Hi All, > > I was looking at the linux kernel, and in the implementation of spinlocks, > one can use different functions. One of them is spin_lock_bh(). What it > does is it creates a spin lock and disables the software irqs. > > In FreeBSD on the other hand, the implementation of spinlocks is done by > mtx_lock_spin (which is actually a macro that calls mtx_lock_spin_flags()) > but the problem is that is disables all the irq vector (at the bottom of > the stack it executes an "cli"). Is there any way one can implement > spinlocks that only disable the bottom half (sof irq)? > > Alternatively, what would be the best way to manualy disable the soft irqs? > > And all this makes me think... Why has nobody implemented a "_bh" version > so far? Is this an architectural decision, or is it just me being blind? Generally one should use a regular mutex to protect data. Spin locks in FreeBSD are only used by scheduler internals or for a driver that has to interact with an INTR_FAST handler (or filter in 7.x+). -- John Baldwin