linux-mips
[Top] [All Lists]

Re: Bug in atomic_sub_if_positive

To: Morten Larsen <mlarsen@broadcom.com>
Subject: Re: Bug in atomic_sub_if_positive
From: Thiemo Seufer <ths@networkno.de>
Date: Wed, 2 Jul 2008 10:59:56 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <ADD7831BD377A74E9A1621D1EAAED18F0450AC61@NT-SJCA-0750.brcm.ad.broadcom.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <ADD7831BD377A74E9A1621D1EAAED18F0450AC61@NT-SJCA-0750.brcm.ad.broadcom.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.18 (2008-05-17)
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"

AFAICS this change should make no difference to the generated code. I
suspect you assembler handles .subsection incorrectly. Can you provide
a disassembled exapmle which gets altered by this patch? Also, please
tell us the exact version of the assembler you use.


Thiemo

<Prev in Thread] Current Thread [Next in Thread>