From: Segher Boessenkool <segher@kernel•crashing.org>
To: Paul Mackerras <paulus@samba•org>
Cc: olof@lixom•net, linuxppc-dev@ozlabs•org
Subject: Re: [PATCH] atomic_dec_if_positive sign extension fix
Date: Mon, 15 Jan 2007 00:32:18 +0100 [thread overview]
Message-ID: <37cdcd37b9252ee18fa458b22e8bdd60@kernel.crashing.org> (raw)
In-Reply-To: <17834.47158.581922.62728@cargo.ozlabs.ibm.com>
>> Please apply for 2.6.20. If an atomic counter is explicitly set to a
>> negative value the atomic_dec_if_positive function will decrement and
>> store the next smallest value in the atomic counter contrary to it's
>> intended operation.
>
> [snip]
>
>> __asm__ __volatile__(
>> LWSYNC_ON_SMP
>> "1: lwarx %0,0,%1 # atomic_dec_if_positive\n\
>> + extsw %0,%0\n\
>> addic. %0,%0,-1\n\
>> blt- 2f\n"
>> PPC405_ERR77(0,%1)
>
> NAK: Good fix for 64-bit, but it will break 32-bit. I think a better
> fix would be to use a cmpwi after the lwarx, and use addi rather than
> addic..
Instead of the "extsw %0,%0" you could do "rlwinm %0,%0,0,0,31"
but I guess it's not worth it.
What is this function supposed to do if it gets 0x80000000 as
input btw? The current code happily makes it 0x7fffffff as
far as I can see? The "rlwinm" thing would fix that ;-) (Or
unfix, if the current behaviour is intended).
Segher
next prev parent reply other threads:[~2007-01-14 23:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-14 22:55 [PATCH] atomic_dec_if_positive sign extension fix Robert Jennings
2007-01-14 23:09 ` Paul Mackerras
2007-01-14 23:20 ` Olof Johansson
2007-01-14 23:32 ` Segher Boessenkool [this message]
2007-01-14 23:43 ` Segher Boessenkool
2007-01-15 8:55 ` Gabriel Paubert
2007-01-15 16:01 ` Segher Boessenkool
2007-01-16 4:28 ` Gabriel Paubert
2007-01-16 8:36 ` Segher Boessenkool
2007-01-16 18:16 ` [PATCH][v2] " Robert Jennings
2007-01-16 20:08 ` Gabriel Paubert
2007-01-17 16:50 ` [PATCH][v3] " Robert Jennings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=37cdcd37b9252ee18fa458b22e8bdd60@kernel.crashing.org \
--to=segher@kernel$(echo .)crashing.org \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=olof@lixom$(echo .)net \
--cc=paulus@samba$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox