linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Paubert <paubert@iram.es>
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 09:55:57 +0100	[thread overview]
Message-ID: <20070115085557.GA4943@iram.es> (raw)
In-Reply-To: <17834.47158.581922.62728@cargo.ozlabs.ibm.com>

On Mon, Jan 15, 2007 at 10:09:42AM +1100, Paul Mackerras wrote:
> Robert Jennings writes:
> 
> > 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..
> 

Indeed, this will also fix the bug that 0x8000000 is considered 
positive since the test was done after the decrement, at the cost
of one additional instrucction in 32 bit mode.

It also avoids clobbering the carry, you don't know whether a future
version of GCC will require explicit clobbers for the carry. For now
they are useless: you can specify "xer" in the clobber list AFAIR but 
no pattern can be split between setters and users of the carry in the
machine description.

	Gabriel

  parent reply	other threads:[~2007-01-15  8:56 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
2007-01-14 23:43     ` Segher Boessenkool
2007-01-15  8:55   ` Gabriel Paubert [this message]
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=20070115085557.GA4943@iram.es \
    --to=paubert@iram.es \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=olof@lixom.net \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).