Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: qemu/qemu
base: 6f05a92ddc73
Choose a base ref
...
head repository: qemu/qemu
compare: 3dd9e54703e6
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jul 12, 2023

  1. virtio-blk: fix host notifier issues during dataplane start/stop

    The main loop thread can consume 100% CPU when using --device
    virtio-blk-pci,iothread=<iothread>. ppoll() constantly returns but
    reading virtqueue host notifiers fails with EAGAIN. The file descriptors
    are stale and remain registered with the AioContext because of bugs in
    the virtio-blk dataplane start/stop code.
    
    The problem is that the dataplane start/stop code involves drain
    operations, which call virtio_blk_drained_begin() and
    virtio_blk_drained_end() at points where the host notifier is not
    operational:
    - In virtio_blk_data_plane_start(), blk_set_aio_context() drains after
      vblk->dataplane_started has been set to true but the host notifier has
      not been attached yet.
    - In virtio_blk_data_plane_stop(), blk_drain() and blk_set_aio_context()
      drain after the host notifier has already been detached but with
      vblk->dataplane_started still set to true.
    
    I would like to simplify ->ioeventfd_start/stop() to avoid interactions
    with drain entirely, but couldn't find a way to do that. Instead, this
    patch accepts the fragile nature of the code and reorders it so that
    vblk->dataplane_started is false during drain operations. This way the
    virtio_blk_drained_begin() and virtio_blk_drained_end() calls don't
    touch the host notifier. The result is that
    virtio_blk_data_plane_start() and virtio_blk_data_plane_stop() have
    complete control over the host notifier and stale file descriptors are
    no longer left in the AioContext.
    
    This patch fixes the 100% CPU consumption in the main loop thread and
    correctly moves host notifier processing to the IOThread.
    
    Fixes: 1665d93 ("virtio-blk: implement BlockDevOps->drained_begin()")
    Reported-by: Lukáš Doktor <ldoktor@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Tested-by: Lukas Doktor <ldoktor@redhat.com>
    Message-id: 20230704151527.193586-1-stefanha@redhat.com
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Stefan Hajnoczi committed Jul 12, 2023
    Copy the full SHA
    75dcb4d View commit details
    Browse the repository at this point in the history
  2. Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu in…

    …to staging
    
    Pull request
    
    # -----BEGIN PGP SIGNATURE-----
    #
    # iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmSvAB0ACgkQnKSrs4Gr
    # c8hVzAgAomXGVhqm/qnQ99SIry+kec9a1Bom4ZprvpEtiHndoq8bw/ujeUlr/XK0
    # CBKdYNYY3R1rSB6yLsV2ea45elk3x/iMqygbJF3QfWxpHfx0l8vs1WB6uSQFqo/E
    # ext1dvP8Czc0BP4MLaijvkW2u0j8qsLQnJcu9JDrRzgD8OqJSlhOxBSmb8VDvDvx
    # am0RMRkYxSl7jn2LFEE4mMfUjy9JJSFhnzP8lMoGH/m8C62Eult2PFDItnTAG8hN
    # IAyNDCDr2LKZwe6DP9JHUKCtqNYUHnGibgKH3k9NKWgUyOHSxqtDUC9vtoTPskGf
    # BRo0XZM7qnSUZCoAhEjvKVWcEkFIkw==
    # =aHUy
    # -----END PGP SIGNATURE-----
    # gpg: Signature made Wed 12 Jul 2023 08:33:49 PM BST
    # gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
    # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
    # gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
    
    * tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
      virtio-blk: fix host notifier issues during dataplane start/stop
    
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    rth7680 committed Jul 12, 2023
    Copy the full SHA
    3dd9e54 View commit details
    Browse the repository at this point in the history