qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Piotras <piotras@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] testandset asm fix
Date: Mon, 7 Feb 2005 14:26:36 +0000	[thread overview]
Message-ID: <da631837050207062638fafbc8@mail.gmail.com> (raw)
In-Reply-To: <42077171.6030308@bellard.org>

What about IRQ latency?


Piotrek

On Mon, 07 Feb 2005 14:47:29 +0100, Fabrice Bellard <fabrice@bellard.org> wrote:
> OK. Anyway, the locking in QEMU is mostly boggus. If SMP is implemented
> someday with host threads, then it will be the right time to correct it !
> 
> Fabrice.
> 
> Paul Brook wrote:
> > The inline assembly used for the x86/x86-64 host testandset routine is bogus.
> > The operand constraints are wrong (Fails to compile at -O0).
> > Also the return value is incorrect. It should return 0 if the lock was
> > successfully acquired.
> >
> > Patch below fixes it. The additional sete test is unnecessary, we can just use
> > the comparison/writeback value.
> >
> > Paul
> >
> > Index: exec-all.h
> > ===================================================================
> > RCS file: /cvsroot/qemu/qemu/exec-all.h,v
> > retrieving revision 1.26
> > diff -u -p -r1.26 exec-all.h
> > --- exec-all.h 10 Jan 2005 23:23:48 -0000 1.26
> > +++ exec-all.h 6 Feb 2005 14:35:43 -0000
> > @@ -392,28 +392,24 @@ static inline int testandset (int *p)
> >  #ifdef __i386__
> >  static inline int testandset (int *p)
> >  {
> > -    char ret;
> > -    long int readval;
> > -
> > -    __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
> > -                          : "=q" (ret), "=m" (*p), "=a" (readval)
> > -                          : "r" (1), "m" (*p), "a" (0)
> > -                          : "memory");
> > -    return ret;
> > +    long int readval = 0;
> > +
> > +    __asm__ __volatile__ ("lock; cmpxchgl %2, %0"
> > +                          : "+m" (*p), "+a" (readval)
> > +                          : "r" (1));
> > +    return readval;
> >  }
> >  #endif
> >
> >  #ifdef __x86_64__
> >  static inline int testandset (int *p)
> >  {
> > -    char ret;
> > -    int readval;
> > -
> > -    __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
> > -                          : "=q" (ret), "=m" (*p), "=a" (readval)
> > -                          : "r" (1), "m" (*p), "a" (0)
> > -                          : "memory");
> > -    return ret;
> > +    long int readval = 0;
> > +
> > +    __asm__ __volatile__ ("lock; cmpxchgl %2, %0"
> > +                          : "+m" (*p), "+a" (readval)
> > +                          : "r" (1));
> > +    return readval;
> >  }
> >  #endif
> >
> >
> >
> > _______________________________________________
> > Qemu-devel mailing list
> > Qemu-devel@nongnu.org
> > http://lists.nongnu.org/mailman/listinfo/qemu-devel
> >
> >
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>

  reply	other threads:[~2005-02-07 14:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-06 14:43 [Qemu-devel] testandset asm fix Paul Brook
2005-02-07 13:03 ` Piotras
2005-02-07 13:47 ` Fabrice Bellard
2005-02-07 14:26   ` Piotras [this message]
2005-02-07 14:28     ` Piotras
2005-02-07 17:34   ` Lennert Buytenhek
2005-02-07 18:46     ` Fabrice Bellard

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=da631837050207062638fafbc8@mail.gmail.com \
    --to=piotras@gmail.com \
    --cc=qemu-devel@nongnu.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).