| To: | linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org> |
|---|---|
| Subject: | [PATCH] Fix __raw_read_trylock() to allow multiple readers |
| From: | Dave Johnson <djohnson+linux-mips@sw.starentnetworks.com> |
| Date: | Mon, 5 Mar 2007 20:50:27 -0500 |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| Sender: | linux-mips-bounce@linux-mips.org |
Code is from linux-mips.org's git tree at 2.6.18 plus some patches
from 2.6.18.7.
I've run into a deadlock that occurs with the following config:
CONFIG_SMP
CONFIG_PREEMPT
An individual call to __raw_read_trylock() will just return failure if
there is already a reader.
Any code that tries to take a read lock by looping around
__raw_read_trylock() can deadlock if there is already a reader and the
lock in question has a mix of irq and non-irq readers.
This is the case in the _read_lock() from BUILD_LOCK_OPS() in
kernel/spinlock.c.
Perhaps someone can confirm this bug by a code inspection, but I
think the below patch will fix the issue.
Patch should apply ok to 2.6.18.7 (and a similar one to >= 2.6.19)
--
Dave Johnson
Starent Networks
======================== PATCH FOLLOWS ========================
Fix __raw_read_trylock() to allow multiple readers.
A deadlock can occur for mixed irq and non-irq rwlock readers if
a 2nd reader attempts to take lock by looping around __raw_read_trylock().
Signed-off-by: Dave Johnson <djohnson+linux-mips@sw.starentnetworks.com>
--- old/include/asm-mips/spinlock.h 2007-03-05 20:34:51.000000000 -0500
+++ new/include/asm-mips/spinlock.h 2007-03-05 20:35:18.000000000 -0500
@@ -249,7 +249,7 @@
" .set noreorder # __raw_read_trylock \n"
" li %2, 0 \n"
"1: ll %1, %3 \n"
- " bnez %1, 2f \n"
+ " bltz %1, 2f \n"
" addu %1, 1 \n"
" sc %1, %0 \n"
" beqzl %1, 1b \n"
@@ -267,7 +267,7 @@
" .set noreorder # __raw_read_trylock \n"
" li %2, 0 \n"
"1: ll %1, %3 \n"
- " bnez %1, 2f \n"
+ " bltz %1, 2f \n"
" addu %1, 1 \n"
" sc %1, %0 \n"
" beqz %1, 1b \n"
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: SMP+PREEMPT causes NULL dereference in khelper on startup, Dave Johnson |
|---|---|
| Next by Date: | Re: Linux kernel 2.6.20, PCI and hpt266, Marco Braga |
| Previous by Thread: | [PATCH] Add some sysfs files to debug unaligned accesses, Atsushi Nemoto |
| Next by Thread: | Re: [PATCH] Fix __raw_read_trylock() to allow multiple readers, Ralf Baechle |
| Indexes: | [Date] [Thread] [Top] [All Lists] |