summary refs log tree commit diff stats
path: root/hw/timer/stm32f2xx_timer.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2015-02-15 11:06:30 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2015-02-27 14:43:45 +0100
commit2e5b887cfc69991eee27be6cc0938c70a360fe45 (patch)
tree7aca623f1700e7fe3bc5fd9c344930eaa73b71dc /hw/timer/stm32f2xx_timer.c
parent2264750483107c45877d29813c497b4c87f64cb6 (diff)
downloadfocaccia-qemu-2e5b887cfc69991eee27be6cc0938c70a360fe45.tar.gz
focaccia-qemu-2e5b887cfc69991eee27be6cc0938c70a360fe45.zip
block: Forbid bdrv_set_aio_context outside BQL
Even if the caller has both the old and the new AioContext's, there can
be a deadlock, due to the leading bdrv_drain_all.

Suppose there are four io threads (A, B, A0, B0) with A and B owning a
BDS for each (bs_a, bs_b); Now A wants to move bs_a to iothread A0, and
B wants to move bs_b to B0, at the same time:

  iothread A                           iothread B
--------------------------------------------------------------------------
  aio_context_acquire(A0) /* OK */     aio_context_acquire(B0) /* OK */
  bdrv_set_aio_context(bs_a, A0)       bdrv_set_aio_context(bs_b, B0)
  -> bdrv_drain_all()                  -> bdrv_drain_all()
     -> acquire A /* OK */               -> acquire A /* blocked */
     -> acquire B /* blocked */          -> acquire B
     ...                                 ...

Deadlock happens because A is waiting for B, and B is waiting for A.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1423969591-23646-2-git-send-email-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/timer/stm32f2xx_timer.c')
0 files changed, 0 insertions, 0 deletions