From mboxrd@z Thu Jan 1 00:00:00 1970 From: mita@miraclelinux.com (Akinobu Mita) Date: Thu, 26 Jan 2006 02:13:18 +0000 Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-Id: <20060126021318.GB6648@miraclelinux.com> List-Id: References: <20060125113206.GD18584@miraclelinux.com> <24086.1138190083@ocs3.ocs.com.au> In-Reply-To: <24086.1138190083@ocs3.ocs.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Keith Owens Cc: linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Russell King , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@vger.kernel.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel On Wed, Jan 25, 2006 at 10:54:43PM +1100, Keith Owens wrote: > Be very, very careful about using these generic *_bit() routines if the > architecture supports non-maskable interrupts. > > NMI events can occur at any time, including when interrupts have been > disabled by *_irqsave(). So you can get NMI events occurring while a > *_bit fucntion is holding a spin lock. If the NMI handler also wants > to do bit manipulation (and they do) then you can get a deadlock > between the original caller of *_bit() and the NMI handler. > > Doing any work that requires spinlocks in an NMI handler is just asking > for deadlock problems. The generic *_bit() routines add a hidden > spinlock behind what was previously a safe operation. I would even say > that any arch that supports any type of NMI event _must_ define its own > bit routines that do not rely on your _atomic_spin_lock_irqsave() and > its hash of spinlocks. At least cris and parisc are using similar *_bit function on SMP. I will add your advise in comment. --- ./include/asm-generic/bitops.h.orig 2006-01-26 10:56:00.000000000 +0900 +++ ./include/asm-generic/bitops.h 2006-01-26 11:01:28.000000000 +0900 @@ -50,6 +50,16 @@ extern raw_spinlock_t __atomic_hash[ATOM * C language equivalents written by Theodore Ts'o, 9/26/92 */ +/* + * NMI events can occur at any time, including when interrupts have been + * disabled by *_irqsave(). So you can get NMI events occurring while a + * *_bit fucntion is holding a spin lock. If the NMI handler also wants + * to do bit manipulation (and they do) then you can get a deadlock + * between the original caller of *_bit() and the NMI handler. + * + * by Keith Owens + */ + static __inline__ void set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BITOP_MASK(nr); From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 26 Jan 2006 02:09:04 +0000 (GMT) Received: from ns.miraclelinux.com ([219.118.163.66]:49878 "EHLO mail01.miraclelinux.com") by ftp.linux-mips.org with ESMTP id S8133644AbWAZCIq (ORCPT ); Thu, 26 Jan 2006 02:08:46 +0000 Received: from mail01 (localhost.localdomain [127.0.0.1]) by mail01.miraclelinux.com (Postfix) with ESMTP id EDE5531C180; Thu, 26 Jan 2006 11:13:11 +0900 (JST) Received: from localhost.localdomain (sshgate.miraclelinux.com []) by mail01.miraclelinux.com ([10.1.0.10]); Thu, 26 Jan 2006 02:13:11 +0000 Received: by localhost.localdomain (Postfix, from userid 1000) id 6EF5D420196; Thu, 26 Jan 2006 11:13:18 +0900 (JST) Date: Thu, 26 Jan 2006 11:13:18 +0900 To: Keith Owens Cc: linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Russell King , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@lists.linux-m68k.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-ID: <20060126021318.GB6648@miraclelinux.com> References: <20060125113206.GD18584@miraclelinux.com> <24086.1138190083@ocs3.ocs.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24086.1138190083@ocs3.ocs.com.au> User-Agent: Mutt/1.5.9i From: mita@miraclelinux.com (Akinobu Mita) Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 10163 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: mita@miraclelinux.com Precedence: bulk X-list: linux-mips On Wed, Jan 25, 2006 at 10:54:43PM +1100, Keith Owens wrote: > Be very, very careful about using these generic *_bit() routines if the > architecture supports non-maskable interrupts. > > NMI events can occur at any time, including when interrupts have been > disabled by *_irqsave(). So you can get NMI events occurring while a > *_bit fucntion is holding a spin lock. If the NMI handler also wants > to do bit manipulation (and they do) then you can get a deadlock > between the original caller of *_bit() and the NMI handler. > > Doing any work that requires spinlocks in an NMI handler is just asking > for deadlock problems. The generic *_bit() routines add a hidden > spinlock behind what was previously a safe operation. I would even say > that any arch that supports any type of NMI event _must_ define its own > bit routines that do not rely on your _atomic_spin_lock_irqsave() and > its hash of spinlocks. At least cris and parisc are using similar *_bit function on SMP. I will add your advise in comment. --- ./include/asm-generic/bitops.h.orig 2006-01-26 10:56:00.000000000 +0900 +++ ./include/asm-generic/bitops.h 2006-01-26 11:01:28.000000000 +0900 @@ -50,6 +50,16 @@ extern raw_spinlock_t __atomic_hash[ATOM * C language equivalents written by Theodore Ts'o, 9/26/92 */ +/* + * NMI events can occur at any time, including when interrupts have been + * disabled by *_irqsave(). So you can get NMI events occurring while a + * *_bit fucntion is holding a spin lock. If the NMI handler also wants + * to do bit manipulation (and they do) then you can get a deadlock + * between the original caller of *_bit() and the NMI handler. + * + * by Keith Owens + */ + static __inline__ void set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BITOP_MASK(nr); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail01.miraclelinux.com (ns.miraclelinux.com [219.118.163.66]) by ozlabs.org (Postfix) with ESMTP id 401F068AD3 for ; Thu, 26 Jan 2006 13:13:13 +1100 (EST) Date: Thu, 26 Jan 2006 11:13:18 +0900 To: Keith Owens Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-ID: <20060126021318.GB6648@miraclelinux.com> References: <20060125113206.GD18584@miraclelinux.com> <24086.1138190083@ocs3.ocs.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <24086.1138190083@ocs3.ocs.com.au> From: mita@miraclelinux.com (Akinobu Mita) Cc: linux-mips@linux-mips.org, linux-ia64@vger.kernel.org, Ian Molton , Andi Kleen , David Howells , linuxppc-dev@ozlabs.org, Greg Ungerer , sparclinux@vger.kernel.org, Miles Bader , Yoshinori Sato , Hirokazu Takata , linuxsh-dev@lists.sourceforge.net, Linus Torvalds , Ivan Kokshaysky , Richard Henderson , Chris Zankel , dev-etrax@axis.com, ultralinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, linuxsh-shmedia-dev@lists.sourceforge.net, linux390@de.ibm.com, Russell King , parisc-linux@parisc-linux.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, Jan 25, 2006 at 10:54:43PM +1100, Keith Owens wrote: > Be very, very careful about using these generic *_bit() routines if the > architecture supports non-maskable interrupts. > > NMI events can occur at any time, including when interrupts have been > disabled by *_irqsave(). So you can get NMI events occurring while a > *_bit fucntion is holding a spin lock. If the NMI handler also wants > to do bit manipulation (and they do) then you can get a deadlock > between the original caller of *_bit() and the NMI handler. > > Doing any work that requires spinlocks in an NMI handler is just asking > for deadlock problems. The generic *_bit() routines add a hidden > spinlock behind what was previously a safe operation. I would even say > that any arch that supports any type of NMI event _must_ define its own > bit routines that do not rely on your _atomic_spin_lock_irqsave() and > its hash of spinlocks. At least cris and parisc are using similar *_bit function on SMP. I will add your advise in comment. --- ./include/asm-generic/bitops.h.orig 2006-01-26 10:56:00.000000000 +0900 +++ ./include/asm-generic/bitops.h 2006-01-26 11:01:28.000000000 +0900 @@ -50,6 +50,16 @@ extern raw_spinlock_t __atomic_hash[ATOM * C language equivalents written by Theodore Ts'o, 9/26/92 */ +/* + * NMI events can occur at any time, including when interrupts have been + * disabled by *_irqsave(). So you can get NMI events occurring while a + * *_bit fucntion is holding a spin lock. If the NMI handler also wants + * to do bit manipulation (and they do) then you can get a deadlock + * between the original caller of *_bit() and the NMI handler. + * + * by Keith Owens + */ + static __inline__ void set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BITOP_MASK(nr); From mboxrd@z Thu Jan 1 00:00:00 1970 From: mita@miraclelinux.com (Akinobu Mita) Date: Thu, 26 Jan 2006 02:13:18 +0000 Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-Id: <20060126021318.GB6648@miraclelinux.com> List-Id: References: <20060125113206.GD18584@miraclelinux.com> <24086.1138190083@ocs3.ocs.com.au> In-Reply-To: <24086.1138190083@ocs3.ocs.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Keith Owens Cc: linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Russell King , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@lists.linux-m68k.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel On Wed, Jan 25, 2006 at 10:54:43PM +1100, Keith Owens wrote: > Be very, very careful about using these generic *_bit() routines if the > architecture supports non-maskable interrupts. > > NMI events can occur at any time, including when interrupts have been > disabled by *_irqsave(). So you can get NMI events occurring while a > *_bit fucntion is holding a spin lock. If the NMI handler also wants > to do bit manipulation (and they do) then you can get a deadlock > between the original caller of *_bit() and the NMI handler. > > Doing any work that requires spinlocks in an NMI handler is just asking > for deadlock problems. The generic *_bit() routines add a hidden > spinlock behind what was previously a safe operation. I would even say > that any arch that supports any type of NMI event _must_ define its own > bit routines that do not rely on your _atomic_spin_lock_irqsave() and > its hash of spinlocks. At least cris and parisc are using similar *_bit function on SMP. I will add your advise in comment. --- ./include/asm-generic/bitops.h.orig 2006-01-26 10:56:00.000000000 +0900 +++ ./include/asm-generic/bitops.h 2006-01-26 11:01:28.000000000 +0900 @@ -50,6 +50,16 @@ extern raw_spinlock_t __atomic_hash[ATOM * C language equivalents written by Theodore Ts'o, 9/26/92 */ +/* + * NMI events can occur at any time, including when interrupts have been + * disabled by *_irqsave(). So you can get NMI events occurring while a + * *_bit fucntion is holding a spin lock. If the NMI handler also wants + * to do bit manipulation (and they do) then you can get a deadlock + * between the original caller of *_bit() and the NMI handler. + * + * by Keith Owens + */ + static __inline__ void set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BITOP_MASK(nr); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751288AbWAZCNT (ORCPT ); Wed, 25 Jan 2006 21:13:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751291AbWAZCNS (ORCPT ); Wed, 25 Jan 2006 21:13:18 -0500 Received: from ns.miraclelinux.com ([219.118.163.66]:54486 "EHLO mail01.miraclelinux.com") by vger.kernel.org with ESMTP id S1750710AbWAZCNP (ORCPT ); Wed, 25 Jan 2006 21:13:15 -0500 Date: Thu, 26 Jan 2006 11:13:18 +0900 To: Keith Owens Cc: linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Russell King , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@vger.kernel.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-ID: <20060126021318.GB6648@miraclelinux.com> References: <20060125113206.GD18584@miraclelinux.com> <24086.1138190083@ocs3.ocs.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24086.1138190083@ocs3.ocs.com.au> User-Agent: Mutt/1.5.9i From: mita@miraclelinux.com (Akinobu Mita) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 25, 2006 at 10:54:43PM +1100, Keith Owens wrote: > Be very, very careful about using these generic *_bit() routines if the > architecture supports non-maskable interrupts. > > NMI events can occur at any time, including when interrupts have been > disabled by *_irqsave(). So you can get NMI events occurring while a > *_bit fucntion is holding a spin lock. If the NMI handler also wants > to do bit manipulation (and they do) then you can get a deadlock > between the original caller of *_bit() and the NMI handler. > > Doing any work that requires spinlocks in an NMI handler is just asking > for deadlock problems. The generic *_bit() routines add a hidden > spinlock behind what was previously a safe operation. I would even say > that any arch that supports any type of NMI event _must_ define its own > bit routines that do not rely on your _atomic_spin_lock_irqsave() and > its hash of spinlocks. At least cris and parisc are using similar *_bit function on SMP. I will add your advise in comment. --- ./include/asm-generic/bitops.h.orig 2006-01-26 10:56:00.000000000 +0900 +++ ./include/asm-generic/bitops.h 2006-01-26 11:01:28.000000000 +0900 @@ -50,6 +50,16 @@ extern raw_spinlock_t __atomic_hash[ATOM * C language equivalents written by Theodore Ts'o, 9/26/92 */ +/* + * NMI events can occur at any time, including when interrupts have been + * disabled by *_irqsave(). So you can get NMI events occurring while a + * *_bit fucntion is holding a spin lock. If the NMI handler also wants + * to do bit manipulation (and they do) then you can get a deadlock + * between the original caller of *_bit() and the NMI handler. + * + * by Keith Owens + */ + static __inline__ void set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BITOP_MASK(nr);