All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Fedorov <serge.fdrv@gmail.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Jeff Epler" <jepler@gmail.com>,
	qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"Blue Swirl" <blauwirbel@gmail.com>
Subject: Re: [Qemu-devel] qemu-arm-static, multiprocess, atomic
Date: Thu, 26 May 2016 15:53:38 +0300	[thread overview]
Message-ID: <5746F1D2.30606@gmail.com> (raw)
In-Reply-To: <91b3837f-f61c-a7d4-5266-964e8e27a839@redhat.com>

On 26/05/16 14:21, Paolo Bonzini wrote:
>
> On 26/05/2016 12:42, Sergey Fedorov wrote:
>> I'm afraid even our recent efforts in
>> multi-threaded TCG won't change the situation. The problem is that it
>> would require to translate somehow ARM's exclusive access monitor to x86
>> model.
>>
> The cmpxchg-based variant would work.  It doesn't implement LL/SC
> exactly, but it works fine if the program is written against GCC atomic
> builtins.

I'm afraid, GCC can still generate ldrex/strex pair for
__atomic_compare_exchange():

    $ cat a.c
    #define atomic_cmpxchg(ptr, old,
    new)                                   \
       
    ({                                                                  \
         typeof(*ptr) _old = (old), _new =
    (new);                           \
         __atomic_compare_exchange(ptr, &_old, &_new,
    0,                    \
             __ATOMIC_SEQ_CST,
    __ATOMIC_SEQ_CST);                           \
        
    _old;                                                              \
        
    })                                                                  


    int cmpexchg(int *ptr, int old, int new)
    {
        return atomic_cmpxchg(ptr, old, new);
    }

    $ arm-linux-gnueabi-gcc -march=armv7-a -O2 -c a.c
    $ arm-linux-gnueabi-objdump -d a.o

    a.o:     file format elf32-littlearm


    Disassembly of section .text:

    00000000 <cmpexchg>:
       0:    e24dd008     sub    sp, sp, #8
       4:    e58d1004     str    r1, [sp, #4]
       8:    f57ff05f     dmb    sy
       c:    e1903f9f     ldrex    r3, [r0]
      10:    e1530001     cmp    r3, r1
      14:    1a000002     bne    24 <cmpexchg+0x24>
      18:    e180cf92     strex    ip, r2, [r0]
      1c:    e35c0000     cmp    ip, #0
      20:    1afffff9     bne    c <cmpexchg+0xc>
      24:    f57ff05f     dmb    sy
      28:    e1a00003     mov    r0, r3
      2c:    e28dd008     add    sp, sp, #8
      30:    e12fff1e     bx    lr

Kind regards,
Sergey

  reply	other threads:[~2016-05-26 12:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 12:34 [Qemu-devel] qemu-arm-static, multiprocess, atomic Jeff Epler
2016-05-26 10:42 ` Sergey Fedorov
2016-05-26 11:21   ` Paolo Bonzini
2016-05-26 12:53     ` Sergey Fedorov [this message]
2016-05-26 15:16       ` Paolo Bonzini

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=5746F1D2.30606@gmail.com \
    --to=serge.fdrv@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=blauwirbel@gmail.com \
    --cc=jepler@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.