mbox

[PULL,00/35] cmpxchg atomic operations

Message ID 1477170324-17783-1-git-send-email-rth@twiddle.net
State New
Headers show

Pull-request

git://github.com/rth7680/qemu.git tags/pull-atomic-20161022

Message

Richard Henderson Oct. 22, 2016, 9:04 p.m. UTC
This is v7, with the additional fix for gcc 4.2, as on Centos 6.


r~


The following changes since commit da158a86c407fa7b9da848b571356a26809d8df9:

  Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-10-20-1' into staging (2016-10-20 14:46:19 +0100)

are available in the git repository at:

  git://github.com/rth7680/qemu.git tags/pull-atomic-20161022

for you to fetch changes up to 278c5beb29ef8b6747a7c9bde403e9fe90cdad9c:

  target-alpha: Emulate LL/SC using cmpxchg helpers (2016-10-20 11:00:46 -0700)

----------------------------------------------------------------
cmpxchg atomic operations

----------------------------------------------------------------
Alex Bennée (1):
      linux-user: enable parallel code generation on clone

Emilio G. Cota (18):
      atomics: add atomic_xor
      atomics: add atomic_op_fetch variants
      target-i386: emulate LOCK'ed cmpxchg using cmpxchg helpers
      target-i386: emulate LOCK'ed OP instructions using atomic helpers
      target-i386: emulate LOCK'ed INC using atomic helper
      target-i386: emulate LOCK'ed NOT using atomic helper
      target-i386: emulate LOCK'ed NEG using cmpxchg helper
      target-i386: emulate LOCK'ed XADD using atomic helper
      target-i386: emulate LOCK'ed BTX ops using atomic helpers
      target-i386: emulate XCHG using atomic helper
      target-i386: remove helper_lock()
      tests: add atomic_add-bench
      target-arm: emulate LL/SC using cmpxchg helpers
      target-arm: emulate SWP with atomic_xchg helper
      target-arm: emulate aarch64's LL/SC using cmpxchg helpers
      linux-user: remove handling of ARM's EXCP_STREX
      linux-user: remove handling of aarch64's EXCP_STREX
      target-arm: remove EXCP_STREX + cpu_exclusive_{test, info}

Richard Henderson (16):
      exec: Avoid direct references to Int128 parts
      int128: Use __int128 if available
      int128: Add int128_make128
      tcg: Add EXCP_ATOMIC
      cputlb: Replace SHIFT with DATA_SIZE
      cputlb: Move probe_write out of softmmu_template.h
      cputlb: Remove includes from softmmu_template.h
      cputlb: Move most of iotlb code out of line
      cputlb: Tidy some macros
      tcg: Add atomic helpers
      tcg: Add atomic128 helpers
      tcg: Add CONFIG_ATOMIC64
      tcg: Emit barriers with parallel_cpus
      target-arm: Rearrange aa32 load and store functions
      target-alpha: Introduce MMU_PHYS_IDX
      target-alpha: Emulate LL/SC using cmpxchg helpers

 Makefile.objs              |   2 +-
 Makefile.target            |   1 +
 atomic_template.h          | 215 +++++++++++++++++++++++++
 configure                  |  62 +++++++-
 cpu-exec-common.c          |   6 +
 cpu-exec.c                 |  30 ++++
 cpus.c                     |   2 +
 cputlb.c                   | 203 ++++++++++++++++++++++--
 exec.c                     |   4 +-
 include/exec/cpu-all.h     |   1 +
 include/exec/exec-all.h    |   1 +
 include/qemu-common.h      |   1 +
 include/qemu/atomic.h      |  67 ++++++--
 include/qemu/int128.h      | 171 +++++++++++++++++++-
 linux-user/main.c          | 312 ++++++------------------------------
 linux-user/syscall.c       |   8 +
 softmmu_template.h         | 104 ++----------
 target-alpha/cpu.h         |  22 +--
 target-alpha/helper.c      |  14 +-
 target-alpha/helper.h      |   9 --
 target-alpha/machine.c     |   2 -
 target-alpha/mem_helper.c  |  73 ---------
 target-alpha/translate.c   | 148 +++++++++--------
 target-arm/cpu.h           |  17 +-
 target-arm/helper-a64.c    | 113 +++++++++++++
 target-arm/helper-a64.h    |   2 +
 target-arm/internals.h     |   4 +-
 target-arm/translate-a64.c | 106 ++++++-------
 target-arm/translate.c     | 344 +++++++++++++++-------------------------
 target-arm/translate.h     |   4 -
 target-i386/helper.h       |   4 +-
 target-i386/mem_helper.c   | 153 ++++++++++++------
 target-i386/translate.c    | 386 +++++++++++++++++++++++++++++----------------
 tcg-runtime.c              |  74 +++++++--
 tcg/tcg-op.c               | 354 +++++++++++++++++++++++++++++++++++++++--
 tcg/tcg-op.h               |  44 ++++++
 tcg/tcg-runtime.h          | 109 +++++++++++++
 tcg/tcg.h                  |  85 ++++++++++
 tests/.gitignore           |   1 +
 tests/Makefile.include     |   4 +-
 tests/atomic_add-bench.c   | 163 +++++++++++++++++++
 tests/test-int128.c        |  22 +--
 translate-all.c            |   1 +
 43 files changed, 2353 insertions(+), 1095 deletions(-)
 create mode 100644 atomic_template.h
 create mode 100644 tests/atomic_add-bench.c

Comments

Peter Maydell Oct. 24, 2016, 10:51 a.m. UTC | #1
On 22 October 2016 at 22:04, Richard Henderson <rth@twiddle.net> wrote:
> This is v7, with the additional fix for gcc 4.2, as on Centos 6.
>
>
> r~
>
>
> The following changes since commit da158a86c407fa7b9da848b571356a26809d8df9:
>
>   Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-10-20-1' into staging (2016-10-20 14:46:19 +0100)
>
> are available in the git repository at:
>
>   git://github.com/rth7680/qemu.git tags/pull-atomic-20161022
>
> for you to fetch changes up to 278c5beb29ef8b6747a7c9bde403e9fe90cdad9c:
>
>   target-alpha: Emulate LL/SC using cmpxchg helpers (2016-10-20 11:00:46 -0700)
>
> ----------------------------------------------------------------
> cmpxchg atomic operations
>
> ----------------------------------------------------------------

This fails to build with clang (OSX and linux):

/Users/pm215/src/qemu-for-merges/target-arm/translate.c:1019:1: error:
unused function 'gen_aa32_ld16ua
' [-Werror,-Wunused-function]
DO_GEN_LD(16ua, MO_UW | MO_ALIGN)
^
/Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
expanded from macro 'DO_GEN_LD'
static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
                   ^
<scratch space>:130:1: note: expanded from here
gen_aa32_ld16ua
^
/Users/pm215/src/qemu-for-merges/target-arm/translate.c:1020:1: error:
unused function 'gen_aa32_ld32ua
' [-Werror,-Wunused-function]
DO_GEN_LD(32ua, MO_UL | MO_ALIGN)
^
/Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
expanded from macro 'DO_GEN_LD'
static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
                   ^
<scratch space>:131:1: note: expanded from here
gen_aa32_ld32ua
^

The other builds passed OK.

thanks
-- PMM
Paolo Bonzini Oct. 24, 2016, 12:37 p.m. UTC | #2
On 24/10/2016 12:51, Peter Maydell wrote:
> On 22 October 2016 at 22:04, Richard Henderson <rth@twiddle.net> wrote:
>> This is v7, with the additional fix for gcc 4.2, as on Centos 6.
>>
>>
>> r~
>>
>>
>> The following changes since commit da158a86c407fa7b9da848b571356a26809d8df9:
>>
>>   Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-10-20-1' into staging (2016-10-20 14:46:19 +0100)
>>
>> are available in the git repository at:
>>
>>   git://github.com/rth7680/qemu.git tags/pull-atomic-20161022
>>
>> for you to fetch changes up to 278c5beb29ef8b6747a7c9bde403e9fe90cdad9c:
>>
>>   target-alpha: Emulate LL/SC using cmpxchg helpers (2016-10-20 11:00:46 -0700)
>>
>> ----------------------------------------------------------------
>> cmpxchg atomic operations
>>
>> ----------------------------------------------------------------
> 
> This fails to build with clang (OSX and linux):
> 
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1019:1: error:
> unused function 'gen_aa32_ld16ua
> ' [-Werror,-Wunused-function]
> DO_GEN_LD(16ua, MO_UW | MO_ALIGN)
> ^
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
> expanded from macro 'DO_GEN_LD'
> static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
>                    ^
> <scratch space>:130:1: note: expanded from here
> gen_aa32_ld16ua
> ^
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1020:1: error:
> unused function 'gen_aa32_ld32ua
> ' [-Werror,-Wunused-function]
> DO_GEN_LD(32ua, MO_UL | MO_ALIGN)
> ^
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
> expanded from macro 'DO_GEN_LD'
> static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
>                    ^
> <scratch space>:131:1: note: expanded from here
> gen_aa32_ld32ua
> ^
> 
> The other builds passed OK.

LLVM bug https://llvm.org/bugs/show_bug.cgi?id=22712:

  we should probably consider the functions to not be in the main
  source file if they were expanded from a macro that was defined
  outside that file. That perhaps doesn't go far enough (consider a
  macro defined in the main source file, that produces several
  functions, where after each macro invocation only a subset of the
  functions is used)

Paolo
Peter Maydell Oct. 24, 2016, 2:02 p.m. UTC | #3
On 24 October 2016 at 13:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 24/10/2016 12:51, Peter Maydell wrote:
>> This fails to build with clang (OSX and linux):
>>
>> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1019:1: error:
>> unused function 'gen_aa32_ld16ua
>> ' [-Werror,-Wunused-function]
>> DO_GEN_LD(16ua, MO_UW | MO_ALIGN)
>> ^
>> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
>> expanded from macro 'DO_GEN_LD'
>> static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
>>                    ^
>> <scratch space>:130:1: note: expanded from here
>> gen_aa32_ld16ua
>> ^
>> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1020:1: error:
>> unused function 'gen_aa32_ld32ua
>> ' [-Werror,-Wunused-function]
>> DO_GEN_LD(32ua, MO_UL | MO_ALIGN)
>> ^
>> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
>> expanded from macro 'DO_GEN_LD'
>> static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
>>                    ^
>> <scratch space>:131:1: note: expanded from here
>> gen_aa32_ld32ua
>> ^
>>
>> The other builds passed OK.
>
> LLVM bug https://llvm.org/bugs/show_bug.cgi?id=22712:
>
>   we should probably consider the functions to not be in the main
>   source file if they were expanded from a macro that was defined
>   outside that file. That perhaps doesn't go far enough (consider a
>   macro defined in the main source file, that produces several
>   functions, where after each macro invocation only a subset of the
>   functions is used)

That just says "even if we fixed this bug it wouldn't affect
the situation we have here"...

In any case, since DO_GEN_LD(16ua, ...) only and exactly produces
one function (gen_aa32_ld16ua), the fix would seem to be just to not
have that macro invocation if we never use the function it produces.
(We don't even conditionally use the function as far as I can tell.)

thanks
-- PMM
Richard Henderson Oct. 24, 2016, 5:27 p.m. UTC | #4
On 10/24/2016 03:51 AM, Peter Maydell wrote:
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1019:1: error:
> unused function 'gen_aa32_ld16ua
> ' [-Werror,-Wunused-function]
> DO_GEN_LD(16ua, MO_UW | MO_ALIGN)
> ^
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:954:20: note:
> expanded from macro 'DO_GEN_LD'
> static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val,      \
>                    ^
> <scratch space>:130:1: note: expanded from here
> gen_aa32_ld16ua
> ^
> /Users/pm215/src/qemu-for-merges/target-arm/translate.c:1020:1: error:
> unused function 'gen_aa32_ld32ua
> ' [-Werror,-Wunused-function]
> DO_GEN_LD(32ua, MO_UL | MO_ALIGN)

Bah.  Annoyingly, even though I didn't configure with --disable-werror, I only
got the warning from clang, which of course flashed by unseen.

Folded the removal of these into the "target-arm: emulate LL/SC using cmpxchg
helpers" patch which removed their use.


r~
Peter Maydell Oct. 24, 2016, 6:02 p.m. UTC | #5
On 24 October 2016 at 18:27, Richard Henderson <rth@twiddle.net> wrote:
> Bah.  Annoyingly, even though I didn't configure with --disable-werror, I only
> got the warning from clang, which of course flashed by unseen.

I think that configure looks for "does this compiler support
the GCC diagnostic pragma" (which clang doesn't) and doesn't enable
werror by default if it doesn't exist, even though often your
combination of config options and system headers won't produce
the warnings that we would need the pragma to suppress.

I usually add -Werror to --extra-cflags.

thanks
-- PMM