| To: | "Markus Gothe" <markus.gothe@27m.se> |
|---|---|
| Subject: | RE: [SPAM] RE: Bug in atomic_sub_if_positive |
| From: | "Morten Larsen" <mlarsen@broadcom.com> |
| Date: | Tue, 1 Jul 2008 17:43:14 -0700 |
| Cc: | linux-mips@linux-mips.org |
| In-reply-to: | <1CA160A5-AC66-4BBF-9C88-0C2B9FF40E6E@27m.se> |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| Sender: | linux-mips-bounce@linux-mips.org |
| Thread-index: | Acjb2qZnclxNhMgNQHeIqx5CltCbqAAALd2g |
| Thread-topic: | [SPAM] RE: Bug in atomic_sub_if_positive |
Thanks for the reply. My main point is that if the sc instruction fails
(returns zero) then we need to start over (with another ll instruction.) It
appears that the current code does not do this correctly. If you have a better
suggestion for a patch, that's fine with me. Below is the code from the
2.6.20.21 kernel, which is (also) working for me.
=:-) Morten
__asm__ __volatile__(
" .set mips3 \n"
"1: ll %1, %2 # atomic_sub_if_positive\n"
" subu %0, %1, %3 \n"
" bltz %0, 1f \n"
" sc %0, %2 \n"
" .set noreorder \n"
" beqz %0, 1b \n"
" subu %0, %1, %3 \n"
" .set reorder \n"
"1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
: "memory");
________________________________
From: Markus Gothe [mailto:markus.gothe@27m.se]
Sent: Tuesday, July 01, 2008 5:29 PM
To: Morten Larsen
Cc: linux-mips@linux-mips.org
Subject: Re: [SPAM] RE: Bug in atomic_sub_if_positive
NACK.
You must realize that 1b stands for 'label 1, backwards', so correctly
it would be '2: b 1f'... Which is a kind off inconsequent numbering in this
case.
//Markus
On 2 Jul 2008, at 02:12, Morten Larsen wrote:
As far as I can tell the branch optimization fixes in
2.6.21 introduced
a bug in atomic_sub_if_positive that causes it to
return even when the
sc instruction fails. The result is that e.g.
down_trylock becomes
unreliable as the semaphore counter is not always
decremented.
Previous patch was garbled by Outlook - this one should be
clean:
--- a/include/asm-mips/atomic.h 2008-06-25 22:38:43.159739000
-0700
+++ b/include/asm-mips/atomic.h 2008-06-25 22:39:07.552065000
-0700
@@ -292,10 +292,10 @@ static __inline__ int atomic_sub_if_posi
" beqz %0, 2f \n"
" subu %0, %1, %3 \n"
" .set reorder \n"
- "1: \n"
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
+ "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
@@ -682,10 +682,10 @@ static __inline__ long atomic64_sub_if_p
" beqz %0, 2f \n"
" dsubu %0, %1, %3 \n"
" .set reorder \n"
- "1: \n"
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
+ "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
_______________________________________
Mr Markus Gothe
Software Engineer
Phone: +46 (0)13 21 81 20 (ext. 1046)
Fax: +46 (0)13 21 21 15
Mobile: +46 (0)70 348 44 35
Diskettgatan 11, SE-583 35 Linköping, Sweden
www.27m.com
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [SPAM] RE: Bug in atomic_sub_if_positive, Markus Gothe |
|---|---|
| Next by Date: | Re: RFC: Adding non-PIC executable support to MIPS, Adam Nemet |
| Previous by Thread: | Re: [SPAM] RE: Bug in atomic_sub_if_positive, Markus Gothe |
| Next by Thread: | Re: Bug in atomic_sub_if_positive, Thiemo Seufer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |