qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 158ef8: qemu-thread: fix qemu_event without f


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 158ef8: qemu-thread: fix qemu_event without futexes
Date: Tue, 03 Feb 2015 03:00:11 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 158ef8cbb7e0fe8bb430310924b8bebe5f186e6e
      
https://github.com/qemu/qemu/commit/158ef8cbb7e0fe8bb430310924b8bebe5f186e6e
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M util/qemu-thread-posix.c

  Log Message:
  -----------
  qemu-thread: fix qemu_event without futexes

This had a possible deadlock that was visible with rcutorture.

    qemu_event_set                    qemu_event_wait
    ----------------------------------------------------------------
                                cmpxchg reads FREE, writes BUSY
                                futex_wait: pthread_mutex_lock
                                futex_wait: value == BUSY
    xchg reads BUSY, writes SET
    futex_wake: pthread_cond_broadcast
                                futex_wait: pthread_cond_wait
                                <deadlock>

The fix is simply to avoid condvar tricks and do the obvious locking
around pthread_cond_broadcast:

    qemu_event_set        qemu_event_wait
    ----------------------------------------------------------------
                                cmpxchg reads FREE, writes BUSY
                                futex_wait: pthread_mutex_lock
                                futex_wait: value == BUSY
    xchg reads BUSY, writes SET
    futex_wake: pthread_mutex_lock
    (blocks)
                                futex_wait: pthread_cond_wait
    (mutex unlocked)
    futex_wake: pthread_cond_broadcast
    futex_wake: pthread_mutex_unlock
                                futex_wait: pthread_mutex_unlock

Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 7911747bd46123ef8d8eef2ee49422bb8a4b274f
      
https://github.com/qemu/qemu/commit/7911747bd46123ef8d8eef2ee49422bb8a4b274f
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    A docs/rcu.txt
    M hw/9pfs/virtio-9p-synth.c
    M include/qemu/atomic.h
    M include/qemu/queue.h
    A include/qemu/rcu.h
    M include/qemu/thread.h
    M util/Makefile.objs
    A util/rcu.c

  Log Message:
  -----------
  rcu: add rcu library

This includes a (mangled) copy of the liburcu code.  The main changes
are: 1) removing dependencies on many other header files in liburcu; 2)
removing for simplicity the tentative busy waiting in synchronize_rcu,
which has limited performance effects; 3) replacing futexes in
synchronize_rcu with QemuEvents for Win32 portability.  The API is
the same as liburcu, so it should be possible in the future to require
liburcu on POSIX systems for example and use our copy only on Windows.

Among the various versions available I chose urcu-mb, which is the
least invasive implementation even though it does not have the
fastest rcu_read_{lock,unlock} implementation.  The urcu flavor can
be changed later, after benchmarking.

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 8fda74a52bf3fa63cb80c877b6946cb9143f96cc
      
https://github.com/qemu/qemu/commit/8fda74a52bf3fa63cb80c877b6946cb9143f96cc
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M tests/Makefile
    A tests/rcutorture.c

  Log Message:
  -----------
  rcu: add rcutorture

rcutorture is the unit test for rcu.

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: d62cb4f2fdc0977f9ca9f41d297c3d2c44874171
      
https://github.com/qemu/qemu/commit/d62cb4f2fdc0977f9ca9f41d297c3d2c44874171
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M include/qemu/rcu.h
    M tests/rcutorture.c

  Log Message:
  -----------
  rcu: allow nesting of rcu_read_lock/rcu_read_unlock

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 26387f86c9d6ac3a7a93b76108c502646afb6c25
      
https://github.com/qemu/qemu/commit/26387f86c9d6ac3a7a93b76108c502646afb6c25
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M docs/rcu.txt
    M include/qemu/rcu.h
    M util/rcu.c

  Log Message:
  -----------
  rcu: add call_rcu

Asynchronous callbacks provided by call_rcu are particularly important
for QEMU, because the BQL makes it hard to use synchronize_rcu.

In addition, the current RCU implementation is not particularly friendly
to multiple concurrent synchronize_rcu callers, making call_rcu even
more important.

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: b476c99d01519277e3494a10dc0329d07157ae02
      
https://github.com/qemu/qemu/commit/b476c99d01519277e3494a10dc0329d07157ae02
  Author: Jan Kiszka <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M memory.c

  Log Message:
  -----------
  memory: remove assertion on memory_region_destroy

Now that memory_region_destroy can be called from an RCU callback,
checking the BQL-protected global memory_region_transaction_depth
does not make much sense.

Signed-off-by: Jan Kiszka <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 374f2981d1f10bc4307f250f24b2a7ddb9b14be0
      
https://github.com/qemu/qemu/commit/374f2981d1f10bc4307f250f24b2a7ddb9b14be0
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: protect current_map by RCU

Replace the flat_view_mutex with RCU, avoiding futex contention for
dataplane on large systems and many iothreads.

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 2b647668c9092dbc26e36a2ece9647cc2f00e05b
      
https://github.com/qemu/qemu/commit/2b647668c9092dbc26e36a2ece9647cc2f00e05b
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M memory.c

  Log Message:
  -----------
  memory: avoid ref/unref in memory_region_find

Do the entire lookup under RCU, which avoids atomic operations
in flatview_ref and flatview_unref.

Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: a498d0ef37cf23e1776240af61f558d113afdf4f
      
https://github.com/qemu/qemu/commit/a498d0ef37cf23e1776240af61f558d113afdf4f
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M cpu-exec.c

  Log Message:
  -----------
  cpu-exec: simplify align_clocks

sc->diff_clk is already equal to sleep_delay (split in a second and a
nanosecond part).  If you subtract sleep_delay - rem_delay, the result
is exactly rem_delay.

Cc: Sebastian Tanase <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 2e91cc62f29a7359d00576a250a10892e00c95b4
      
https://github.com/qemu/qemu/commit/2e91cc62f29a7359d00576a250a10892e00c95b4
  Author: Paolo Bonzini <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M cpu-exec.c
    M cpus.c
    M include/qemu/timer.h

  Log Message:
  -----------
  cpu-exec: simplify init_delay_params

With the introduction of QEMU_CLOCK_VIRTUAL_RT, the computation of
sc->diff_clk can be simplified nicely:
   qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
  qemu_clock_get_ns(QEMU_CLOCK_REALTIME) +
  cpu_get_clock_offset()

     =  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
  (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - cpu_get_clock_offset())

     =  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
  (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timers_state.cpu_clock_offset)

     =  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT)

Cc: Sebastian Tanase <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: 2aeba9d8a1b6121b98948fcd42fd2aa32f68b750
      
https://github.com/qemu/qemu/commit/2aeba9d8a1b6121b98948fcd42fd2aa32f68b750
  Author: Fam Zheng <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M hw/scsi/scsi-bus.c

  Log Message:
  -----------
  scsi: Fix scsi_req_cancel_async for no aiocb req

scsi_req_cancel_complete is responsible for releasing the request, so we
shouldn't skip it in any case. This doesn't affect the only existing
caller, virtio-scsi, but is useful for other devices once they use it.

Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>


  Commit: d5fbb4c9ed52d97aebe5994d8a857c74c0d95a92
      
https://github.com/qemu/qemu/commit/d5fbb4c9ed52d97aebe5994d8a857c74c0d95a92
  Author: Peter Maydell <address@hidden>
  Date:   2015-02-02 (Mon, 02 Feb 2015)

  Changed paths:
    M cpu-exec.c
    M cpus.c
    A docs/rcu.txt
    M hw/9pfs/virtio-9p-synth.c
    M hw/scsi/scsi-bus.c
    M include/exec/memory.h
    M include/qemu/atomic.h
    M include/qemu/queue.h
    A include/qemu/rcu.h
    M include/qemu/thread.h
    M include/qemu/timer.h
    M memory.c
    M tests/Makefile
    A tests/rcutorture.c
    M util/Makefile.objs
    M util/qemu-thread-posix.c
    A util/rcu.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

The important bits here are the first part of RCU.

v1->v2 changes are the new qemu-thread patch to fix Mac OS X,
and cleaning up warnings.

v2->v3 removed the patch to enable modules by default.

# gpg: Signature made Mon 02 Feb 2015 19:28:03 GMT using RSA key ID 78C7AE83
# gpg: Good signature from "Paolo Bonzini <address@hidden>"
# gpg:                 aka "Paolo Bonzini <address@hidden>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream:
  scsi: Fix scsi_req_cancel_async for no aiocb req
  cpu-exec: simplify init_delay_params
  cpu-exec: simplify align_clocks
  memory: avoid ref/unref in memory_region_find
  memory: protect current_map by RCU
  memory: remove assertion on memory_region_destroy
  rcu: add call_rcu
  rcu: allow nesting of rcu_read_lock/rcu_read_unlock
  rcu: add rcutorture
  rcu: add rcu library
  qemu-thread: fix qemu_event without futexes

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/16017c485479...d5fbb4c9ed52

reply via email to

[Prev in Thread] Current Thread [Next in Thread]