public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Abhishek Deb <adeb@nvidia.com>
To: Dinar Temirbulatov <dinar@kugelworks.com>
Cc: "libc-ports@sourceware.org" <libc-ports@sourceware.org>,
	"joseph@codesourcery.com" <joseph@codesourcery.com>
Subject: RE: [Patch] ARM define atomic_exchange_acq/atomic_exchange_rel to __atomic_exchange_n
Date: Sat, 17 Aug 2013 02:42:00 -0000	[thread overview]
Message-ID: <0E42B6C0C4628E48B8DF5D3F3C8FCA8898F288A272@HQMAIL02.nvidia.com> (raw)
In-Reply-To: <CANoaTN0MFzWmG8e7cuWkw067qp_p_UgsABtBXCcY+8CZRADzeg@mail.gmail.com>

Dinar,

As I said currently __arch_compare_and_exchange_val_32_acq is defined to __sync_val_compare_and_swap ((mem), (oldval), (newval)), which probably uses two dmb. 
Can't __atomic_compare_exchange_n be used and appropriate memodel be specified for acquire and release variants?

-----Original Message-----
From: Dinar Temirbulatov [mailto:dinar@kugelworks.com] 
Sent: Friday, August 16, 2013 3:58 PM
To: Abhishek Deb
Cc: libc-ports@sourceware.org; joseph@codesourcery.com
Subject: Re: [Patch] ARM define atomic_exchange_acq/atomic_exchange_rel to __atomic_exchange_n

Hello Abhishek,

>However, taking a deeper look into atomic_compare_and_exchange_acq/rel, following is how the compiled code looks like
>
>  34:   f57ff05f        dmb     sy
>  38:   e1903f9f        ldrex   r3, [r0]
>  3c:   e3530000        cmp     r3, #0
>  40:   1a000002        bne     50
>  44:   e1801f92        strex   r1, r2, [r0]
>  48:   e3510000        cmp     r1, #0
>  4c:   1afffff9        bne     38
>  50:   e3530000        cmp     r3, #0
>  54:   f57ff05f        dmb     sy
>  58:   1afffff5        bne     34
oh, I see that lll_unlock looks correct on my side:
.LBB12:
        .loc 1 42 0
        dmb     sy
.L21:
        ldrex   r2, [r4]
        strex   r1, r3, [r4]
        cmp     r1, #0
        bne     .L21
.LVL10:

and for example __lll_cond_lock/__lll_timedlock also look right.

But, I see that for  lll_lock defined as :
#define __lll_lock(futex, private)                                            \
  ((void) ({                                                                  \
    int *__futex = (futex);                                                   \
    if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex,       \
                                                                1, 0), 0))    \
      {                                                                       \
        if (__builtin_constant_p (private) && (private) == LLL_PRIVATE)       \
          __lll_lock_wait_private (__futex);                                  \
        else                                                                  \
          __lll_lock_wait (__futex, private);                                 \
      }                                                                       \
  }))

and we could see that on instruction level it looks like this:
        dmb     sy
.L91:
        ldrex   r0, [r4]
        cmp     r0, r3
        bne     .L92
        strex   r1, r7, [r4]
        cmp     r1, #0
        bne     .L91
.L92:
.LBE10:
        .loc 1 204 0
        cmp     r3, r0
.LBB11:
        .loc 1 202 0
        dmb     sy

, so nothing wrong on my side.
              thanks, Dinar.

  reply	other threads:[~2013-08-17  2:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13 17:11 Dinar Temirbulatov
2013-08-15 21:46 ` Abhishek Deb
2013-08-16 22:57   ` Dinar Temirbulatov
2013-08-17  2:42     ` Abhishek Deb [this message]
2013-08-19 19:21       ` Dinar Temirbulatov
2013-08-18 20:29 ` Joseph S. Myers
2013-09-01 20:42 Dinar Temirbulatov
2013-09-01 20:43 Dinar Temirbulatov
2013-09-02 15:08 ` Joseph S. Myers
2013-09-03 17:31   ` Abhishek Deb
2013-09-05 12:56   ` Dinar Temirbulatov
2013-09-05 15:48     ` Joseph S. Myers
2013-09-05 17:09       ` Abhishek Deb
2013-09-11 19:25         ` Dinar Temirbulatov
2013-09-11 19:27         ` Dinar Temirbulatov
2013-09-11 20:40           ` Abhishek Deb
2013-09-13 17:14           ` Joseph S. Myers
2013-09-14  3:29             ` Dinar Temirbulatov
2013-09-18 17:16               ` Joseph S. Myers
2013-09-19  6:53                 ` Maxim Kuvyrkov
2013-09-19 16:29                   ` Joseph S. Myers

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=0E42B6C0C4628E48B8DF5D3F3C8FCA8898F288A272@HQMAIL02.nvidia.com \
    --to=adeb@nvidia.com \
    --cc=dinar@kugelworks.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-ports@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).