Skip to content
Snippets Groups Projects
  1. Apr 09, 2020
    • Paolo Bonzini's avatar
      async: use explicit memory barriers · 5710a3e0
      Paolo Bonzini authored
      
      When using C11 atomics, non-seqcst reads and writes do not participate
      in the total order of seqcst operations.  In util/async.c and util/aio-posix.c,
      in particular, the pattern that we use
      
                write ctx->notify_me                 write bh->scheduled
                read bh->scheduled                   read ctx->notify_me
                if !bh->scheduled, sleep             if ctx->notify_me, notify
      
      needs to use seqcst operations for both the write and the read.  In
      general this is something that we do not want, because there can be
      many sources that are polled in addition to bottom halves.  The
      alternative is to place a seqcst memory barrier between the write
      and the read.  This also comes with a disadvantage, in that the
      memory barrier is implicit on strongly-ordered architectures and
      it wastes a few dozen clock cycles.
      
      Fortunately, ctx->notify_me is never written concurrently by two
      threads, so we can assert that and relax the writes to ctx->notify_me.
      The resulting solution works and performs well on both aarch64 and x86.
      
      Note that the atomic_set/atomic_read combination is not an atomic
      read-modify-write, and therefore it is even weaker than C11 ATOMIC_RELAXED;
      on x86, ATOMIC_RELAXED compiles to a locked operation.
      
      Analyzed-by: default avatarYing Fang <fangying1@huawei.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: default avatarYing Fang <fangying1@huawei.com>
      Message-Id: <20200407140746.8041-6-pbonzini@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      5710a3e0
    • Paolo Bonzini's avatar
      aio-wait: delegate polling of main AioContext if BQL not held · 3c18a92d
      Paolo Bonzini authored
      
      Any thread that is not a iothread returns NULL for qemu_get_current_aio_context().
      As a result, it would also return true for
      in_aio_context_home_thread(qemu_get_aio_context()), causing
      AIO_WAIT_WHILE to invoke aio_poll() directly.  This is incorrect
      if the BQL is not held, because aio_poll() does not expect to
      run concurrently from multiple threads, and it can actually
      happen when savevm writes to the vmstate file from the
      migration thread.
      
      Therefore, restrict in_aio_context_home_thread to return true
      for the main AioContext only if the BQL is held.
      
      The function is moved to aio-wait.h because it is mostly used
      there and to avoid a circular reference between main-loop.h
      and block/aio.h.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200407140746.8041-5-pbonzini@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      3c18a92d
    • Stefan Hajnoczi's avatar
      aio-posix: signal-proof fdmon-io_uring · 636b836d
      Stefan Hajnoczi authored
      
      The io_uring_enter(2) syscall returns with errno=EINTR when interrupted
      by a signal.  Retry the syscall in this case.
      
      It's essential to do this in the io_uring_submit_and_wait() case.  My
      interpretation of the Linux v5.5 io_uring_enter(2) code is that it
      shouldn't affect the io_uring_submit() case, but there is no guarantee
      this will always be the case.  Let's check for -EINTR around both APIs.
      
      Note that the liburing APIs have -errno return values.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-id: 20200408091139.273851-1-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      636b836d
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/rth/tags/pull-rx-20200408' into staging · 8bac3ba5
      Peter Maydell authored
      
      Add fall through comment for Coverity.
      
      # gpg: Signature made Wed 08 Apr 2020 16:28:12 BST
      # gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
      # gpg:                issuer "richard.henderson@linaro.org"
      # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
      # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F
      
      * remotes/rth/tags/pull-rx-20200408:
        target/rx/translate: Add missing fall through comment
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8bac3ba5
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/xtensa/tags/20200407-xtensa' into staging · bb2e2bfc
      Peter Maydell authored
      
      target/xtensa fixes for 5.0:
      
      - fix pasto in pfwait.r opcode name;
      - fix memory leak with dynamically allocated xtensa_insnbufs in
        DisasContext.
      
      # gpg: Signature made Wed 08 Apr 2020 00:58:05 BST
      # gpg:                using RSA key 2B67854B98E5327DCDEB17D851F9CC91F83FA044
      # gpg:                issuer "jcmvbkbc@gmail.com"
      # gpg: Good signature from "Max Filippov <filippov@cadence.com>" [unknown]
      # gpg:                 aka "Max Filippov <max.filippov@cogentembedded.com>" [full]
      # gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>" [full]
      # Primary key fingerprint: 2B67 854B 98E5 327D CDEB  17D8 51F9 CC91 F83F A044
      
      * remotes/xtensa/tags/20200407-xtensa:
        target/xtensa: statically allocate xtensa_insnbufs in DisasContext
        target/xtensa: fix pasto in pfwait.r opcode name
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      bb2e2bfc
  2. Apr 08, 2020
  3. Apr 07, 2020
Loading