Skip to content

migration: fix deadlock

Denis V. Lunev qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 10 repliesIn review
  2. v11 patch 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2migration: bitmap_set is unnecessary as bitmap_new uses g_try_malloc0migration/ram.c+0 -24 replies
2/2migration: fix deadlockmigration/ram.c+28 -151 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/2] migration: fix deadlock

Release qemu global mutex before call synchronize_rcu(). synchronize_rcu() waiting for all readers to finish their critical sections. There is at least one critical section in which we try to get QGM (critical section is in address_space_rw() and prepare_mmio_access() is trying to aquire QGM).

Both functions (migration_end() and migration_bitmap_extend()) are called from main thread which is holding QGM.

Thus there is a race condition that ends up with deadlock:
main thread working thread
Lock QGA |

|             Call KVM_EXIT_IO handler
|                       |
|        Open rcu reader's critical section
Migration cleanup bh    |
|                       |
synchronize_rcu() is    |
waiting for readers     |

| prepare_mmio_access() is waiting for QGM
\ /
deadlock

Patches here are quick and dirty, compile-tested only to validate the architectual approach.

Igor, Anna, can you pls start your tests with these patches instead of your original one. Thank you.

CC Igor Redko <[email protected]>
CC Anna Melekhova <[email protected]>
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>

Denis V. Lunev (2):
migration: bitmap_set is unnecessary as bitmap_new uses g_try_malloc0
migration: fix deadlock

 migration/ram.c | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)
Signature · 1 line
2.1.4