[Top][All Lists]

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

[Qemu-commits] [qemu/qemu] 69de48: test-bdrv-drain: fix iothread_join()

From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 69de48: test-bdrv-drain: fix iothread_join() hang
Date: Tue, 15 Oct 2019 04:00:06 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 69de48445a0d6169f1e2a6c5bfab994e1c810e33
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2019-10-14 (Mon, 14 Oct 2019)

  Changed paths:
    M tests/iothread.c

  Log Message:
  test-bdrv-drain: fix iothread_join() hang

tests/test-bdrv-drain can hang in tests/iothread.c:iothread_run():

  while (!atomic_read(&iothread->stopping)) {
      aio_poll(iothread->ctx, true);

The iothread_join() function works as follows:

  void iothread_join(IOThread *iothread)
      iothread->stopping = true;

If iothread_run() checks iothread->stopping before the iothread_join()
thread sets stopping to true, then aio_notify() may be optimized away
and iothread_run() hangs forever in aio_poll().

The correct way to change iothread->stopping is from a BH that executes
within iothread_run().  This ensures that iothread->stopping is checked
after we set it to true.

This was already fixed for ./iothread.c (note this is a different source
file!) by commit 2362a28ea11c145e1a13ae79342d76dc118a72a6 ("iothread:
fix iothread_stop() race condition"), but not for tests/iothread.c.

Fixes: 0c330a734b51c177ab8488932ac3b0c4d63a718a
       ("aio: introduce aio_co_schedule and aio_co_wake")
Reported-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>

  Commit: 3779d1801166cc27b91f88366dd5bbae6b1c6dde
  Author: Peter Maydell <address@hidden>
  Date:   2019-10-15 (Tue, 15 Oct 2019)

  Changed paths:
    M tests/iothread.c

  Log Message:
  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into 

Pull request

# gpg: Signature made Mon 14 Oct 2019 09:52:03 BST
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <address@hidden>" [full]
# gpg:                 aka "Stefan Hajnoczi <address@hidden>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  test-bdrv-drain: fix iothread_join() hang

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

Compare: https://github.com/qemu/qemu/compare/4a512a95bbca...3779d1801166

reply via email to

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