qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] cd0c0d: block/file-posix: set up Linux AIO an


From: Alex Bennée
Subject: [Qemu-commits] [qemu/qemu] cd0c0d: block/file-posix: set up Linux AIO and io_uring in...
Date: Thu, 21 Dec 2023 16:45:02 -0800

  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: cd0c0db0aa905af9b72735d5ea40cb41206c7ca8
      
https://github.com/qemu/qemu/commit/cd0c0db0aa905af9b72735d5ea40cb41206c7ca8
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block/file-posix.c

  Log Message:
  -----------
  block/file-posix: set up Linux AIO and io_uring in the current thread

The file-posix block driver currently only sets up Linux AIO and
io_uring in the BDS's AioContext. In the multi-queue block layer we must
be able to submit I/O requests in AioContexts that do not have Linux AIO
and io_uring set up yet since any thread can call into the block driver.

Set up Linux AIO and io_uring for the current AioContext during request
submission. We lose the ability to return an error from
.bdrv_file_open() when Linux AIO and io_uring setup fails (e.g. due to
resource limits). Instead the user only gets warnings and we fall back
to aio=threads. This is still better than a fatal error after startup.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230914140101.1065008-2-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 9c67f33fcab654d6b7f9f4236c5a21ea946e0931
      
https://github.com/qemu/qemu/commit/9c67f33fcab654d6b7f9f4236c5a21ea946e0931
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/block/virtio-blk.c
    M include/hw/virtio/virtio-blk.h

  Log Message:
  -----------
  virtio-blk: add lock to protect s->rq

s->rq is accessed from IO_CODE and GLOBAL_STATE_CODE. Introduce a lock
to protect s->rq and eliminate reliance on the AioContext lock.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230914140101.1065008-3-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: c1135913c655ecfac2f3074671663f4251c8177f
      
https://github.com/qemu/qemu/commit/c1135913c655ecfac2f3074671663f4251c8177f
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/block/virtio-blk.c

  Log Message:
  -----------
  virtio-blk: don't lock AioContext in the completion code path

Nothing in the completion code path relies on the AioContext lock
anymore. Virtqueues are only accessed from one thread at any moment and
the s->rq global state is protected by its own lock now.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230914140101.1065008-4-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 6b5aa3a0fdfc74d42f9f7705fa6ced73253b06b1
      
https://github.com/qemu/qemu/commit/6b5aa3a0fdfc74d42f9f7705fa6ced73253b06b1
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/block/virtio-blk.c

  Log Message:
  -----------
  virtio-blk: don't lock AioContext in the submission code path

There is no need to acquire the AioContext lock around blk_aio_*() or
blk_get_geometry() anymore. I/O plugging (defer_call()) also does not
require the AioContext lock anymore.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230914140101.1065008-5-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: d3007d348adaaf04ee8b099a475282034a662414
      
https://github.com/qemu/qemu/commit/d3007d348adaaf04ee8b099a475282034a662414
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block/snapshot.c

  Log Message:
  -----------
  block: Fix crash when loading snapshot on inactive node

bdrv_is_read_only() only checks if the node is configured to be
read-only eventually, but even if it returns false, writing to the node
may not be permitted at the moment (because it's inactive).

bdrv_is_writable() checks that the node can be written to right now, and
this is what the snapshot operations really need.

Change bdrv_can_snapshot() to use bdrv_is_writable() to fix crashes like
the following:

$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: ../block/io.c:1990: int bdrv_co_write_req_prepare(BdrvChild 
*, int64_t, int64_t, BdrvTrackedRequest *, int): Assertion `!(bs->open_flags & 
BDRV_O_INACTIVE)' failed.

The resulting error message after this patch isn't perfect yet, but at
least it doesn't crash any more:

$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: Device 'ide0-hd0' is writable but does not support snapshots

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231201142520.32255-2-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 5a7f21efaf99c60614fe1967be1c0f9aa46c526e
      
https://github.com/qemu/qemu/commit/5a7f21efaf99c60614fe1967be1c0f9aa46c526e
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M system/vl.c

  Log Message:
  -----------
  vl: Improve error message for conflicting -incoming and -loadvm

Currently, the conflict between -incoming and -loadvm is only detected
when loading the snapshot fails because the image is still inactive for
the incoming migration. This results in a suboptimal error message:

$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: Device 'ide0-hd0' is writable but does not support snapshots

Catch the situation already in qemu_validate_options() to improve the
message:

$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: 'incoming' and 'loadvm' options are mutually exclusive

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231201142520.32255-3-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: bb6e2511eb48539b7dcbcb5f47772e156b9c45d1
      
https://github.com/qemu/qemu/commit/bb6e2511eb48539b7dcbcb5f47772e156b9c45d1
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    A tests/qemu-iotests/tests/qcow2-internal-snapshots
    A tests/qemu-iotests/tests/qcow2-internal-snapshots.out

  Log Message:
  -----------
  iotests: Basic tests for internal snapshots

We have a few test cases that include tests for corner case aspects of
internal snapshots, but nothing that tests that they actually function
as snapshots or that involves deleting a snapshot. Add a test for this
kind of basic internal snapshot functionality.

The error cases include a regression test for the crash we just fixed
with snapshot operations on inactive images.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231201142520.32255-4-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: eaad0fe26050c227dc5dad63205835bac4912a51
      
https://github.com/qemu/qemu/commit/eaad0fe26050c227dc5dad63205835bac4912a51
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

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

  Log Message:
  -----------
  scsi: only access SCSIDevice->requests from one thread

Stop depending on the AioContext lock and instead access
SCSIDevice->requests from only one thread at a time:
- When the VM is running only the BlockBackend's AioContext may access
  the requests list.
- When the VM is stopped only the main loop may access the requests
  list.

These constraints protect the requests list without the need for locking
in the I/O code path.

Note that multiple IOThreads are not supported yet because the code
assumes all SCSIRequests are executed from a single AioContext. Leave
that as future work.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231204164259.1515217-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 765ca516069a40e2ea7081997a508892db084c8e
      
https://github.com/qemu/qemu/commit/765ca516069a40e2ea7081997a508892db084c8e
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/scsi/virtio-scsi-dataplane.c

  Log Message:
  -----------
  virtio-scsi: don't lock AioContext around 
virtio_queue_aio_attach_host_notifier()

virtio_queue_aio_attach_host_notifier() does not require the AioContext
lock. Stop taking the lock and add an explicit smp_wmb() because we were
relying on the implicit barrier in the AioContext lock before.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231204164259.1515217-3-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 14042268045596a89f3fae3606389536d4784113
      
https://github.com/qemu/qemu/commit/14042268045596a89f3fae3606389536d4784113
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/scsi/scsi-disk.c
    M hw/scsi/scsi-generic.c

  Log Message:
  -----------
  scsi: don't lock AioContext in I/O code path

blk_aio_*() doesn't require the AioContext lock and the SCSI subsystem's
internal state also does not anymore.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231204164259.1515217-4-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: e661a2470342d6fa873369c81988a19b1bb7b3f4
      
https://github.com/qemu/qemu/commit/e661a2470342d6fa873369c81988a19b1bb7b3f4
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M system/dma-helpers.c

  Log Message:
  -----------
  dma-helpers: don't lock AioContext in dma_blk_cb()

Commit abfcd2760b3e ("dma-helpers: prevent dma_blk_cb() vs
dma_aio_cancel() race") acquired the AioContext lock inside dma_blk_cb()
to avoid a race with scsi_device_purge_requests() running in the main
loop thread.

The SCSI code no longer calls dma_aio_cancel() from the main loop thread
while I/O is running in the IOThread AioContext. Therefore it is no
longer necessary to take this lock to protect DMAAIOCB fields. The
->cb() function also does not require the lock because blk_aio_*() and
friends do not need the AioContext lock.

Both hw/ide/core.c and hw/ide/macio.c also call dma_blk_io() but don't
rely on it taking the AioContext lock, so this change is safe.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231204164259.1515217-5-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: ed18b1ed4f34888872b5fbc2f217c65d62c95cfd
      
https://github.com/qemu/qemu/commit/ed18b1ed4f34888872b5fbc2f217c65d62c95cfd
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/scsi/virtio-scsi.c
    M include/hw/virtio/virtio-scsi.h

  Log Message:
  -----------
  virtio-scsi: replace AioContext lock with tmf_bh_lock

Protect the Task Management Function BH state with a lock. The TMF BH
runs in the main loop thread. An IOThread might process a TMF at the
same time as the TMF BH is running. Therefore tmf_bh_list and tmf_bh
must be protected by a lock.

Run TMF request completion in the IOThread using aio_wait_bh_oneshot().
This avoids more locking to protect the virtqueue and SCSI layer state.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 10bcb0d996634aec642b000f05a72c93b652b2e6
      
https://github.com/qemu/qemu/commit/10bcb0d996634aec642b000f05a72c93b652b2e6
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/scsi/scsi-disk.c
    M system/dma-helpers.c

  Log Message:
  -----------
  scsi: assert that callbacks run in the correct AioContext

Since the removal of AioContext locking, the correctness of the code
relies on running requests from a single AioContext at any given time.

Add assertions that verify that callbacks are invoked in the correct
AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231205182011.1976568-3-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: b3496d129bf730524a52a958157b4e6c2d624e67
      
https://github.com/qemu/qemu/commit/b3496d129bf730524a52a958157b4e6c2d624e67
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M tests/unit/test-aio.c

  Log Message:
  -----------
  tests: remove aio_context_acquire() tests

The aio_context_acquire() API is being removed. Drop the test case that
calls the API.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-4-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: b5f4fda4fb773257e142429e4fe78bbdea771075
      
https://github.com/qemu/qemu/commit/b5f4fda4fb773257e142429e4fe78bbdea771075
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M util/async.c

  Log Message:
  -----------
  aio: make aio_context_acquire()/aio_context_release() a no-op

aio_context_acquire()/aio_context_release() has been replaced by
fine-grained locking to protect state shared by multiple threads. The
AioContext lock still plays the role of balancing locking in
AIO_WAIT_WHILE() and many functions in QEMU either require that the
AioContext lock is held or not held for this reason. In other words, the
AioContext lock is purely there for consistency with itself and serves
no real purpose anymore.

Stop actually acquiring/releasing the lock in
aio_context_acquire()/aio_context_release() so that subsequent patches
can remove callers across the codebase incrementally.

I have performed "make check" and qemu-iotests stress tests across
x86-64, ppc64le, and aarch64 to confirm that there are no failures as a
result of eliminating the lock.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-5-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 6bc30f19498547fac9cef98316a65cf6c1f14205
      
https://github.com/qemu/qemu/commit/6bc30f19498547fac9cef98316a65cf6c1f14205
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block.c
    M block/backup.c
    M block/blklogwrites.c
    M block/blkverify.c
    M block/block-backend.c
    M block/commit.c
    M block/graph-lock.c
    M block/mirror.c
    M block/qcow2.c
    M block/quorum.c
    M block/replication.c
    M block/snapshot.c
    M block/stream.c
    M block/vmdk.c
    M blockdev.c
    M blockjob.c
    M include/block/graph-lock.h
    M scripts/block-coroutine-wrapper.py
    M tests/unit/test-bdrv-drain.c
    M tests/unit/test-bdrv-graph-mod.c

  Log Message:
  -----------
  graph-lock: remove AioContext locking

Stop acquiring/releasing the AioContext lock in
bdrv_graph_wrlock()/bdrv_graph_unlock() since the lock no longer has any
effect.

The distinction between bdrv_graph_wrunlock() and
bdrv_graph_wrunlock_ctx() becomes meaningless and they can be collapsed
into one function.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-6-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: b49f4755c7fa35ea6e17e5b52c1cdaef6b4aa21c
      
https://github.com/qemu/qemu/commit/b49f4755c7fa35ea6e17e5b52c1cdaef6b4aa21c
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block.c
    M block/block-backend.c
    M block/copy-before-write.c
    M block/export/export.c
    M block/io.c
    M block/mirror.c
    M block/monitor/bitmap-qmp-cmds.c
    M block/monitor/block-hmp-cmds.c
    M block/qapi-sysemu.c
    M block/qapi.c
    M block/raw-format.c
    M block/replication.c
    M block/snapshot.c
    M block/write-threshold.c
    M blockdev.c
    M blockjob.c
    M hw/block/dataplane/virtio-blk.c
    M hw/block/dataplane/xen-block.c
    M hw/block/virtio-blk.c
    M hw/core/qdev-properties-system.c
    M include/block/block-global-state.h
    M include/block/block-io.h
    M include/block/snapshot.h
    M job.c
    M migration/block.c
    M migration/migration-hmp-cmds.c
    M migration/savevm.c
    M net/colo-compare.c
    M qemu-img.c
    M qemu-io.c
    M qemu-nbd.c
    M replay/replay-debugging.c
    M scripts/block-coroutine-wrapper.py
    M tests/tsan/suppressions.tsan
    M tests/unit/test-bdrv-drain.c
    M tests/unit/test-bdrv-graph-mod.c
    M tests/unit/test-block-iothread.c
    M tests/unit/test-blockjob.c
    M tests/unit/test-replication.c
    M util/async.c
    M util/vhost-user-server.c

  Log Message:
  -----------
  block: remove AioContext locking

This is the big patch that removes
aio_context_acquire()/aio_context_release() from the block layer and
affected block layer users.

There isn't a clean way to split this patch and the reviewers are likely
the same group of people, so I decided to do it in one patch.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-ID: <20231205182011.1976568-7-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: c43d5bc8581d98f82b335f549d10793214e9971b
      
https://github.com/qemu/qemu/commit/c43d5bc8581d98f82b335f549d10793214e9971b
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block.c
    M blockdev.c
    M include/block/block-global-state.h

  Log Message:
  -----------
  block: remove bdrv_co_lock()

The bdrv_co_lock() and bdrv_co_unlock() functions are already no-ops.
Remove them.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231205182011.1976568-8-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 4f36b1384756914a6c4ffe04080a96da149c4c03
      
https://github.com/qemu/qemu/commit/4f36b1384756914a6c4ffe04080a96da149c4c03
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/scsi/scsi-bus.c
    M hw/scsi/scsi-disk.c
    M hw/scsi/virtio-scsi.c
    M include/hw/virtio/virtio-scsi.h

  Log Message:
  -----------
  scsi: remove AioContext locking

The AioContext lock no longer has any effect. Remove it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-9-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 95bbddf9ad539df5d380d563796f85e11107aebb
      
https://github.com/qemu/qemu/commit/95bbddf9ad539df5d380d563796f85e11107aebb
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M include/block/aio-wait.h

  Log Message:
  -----------
  aio-wait: draw equivalence between AIO_WAIT_WHILE() and 
AIO_WAIT_WHILE_UNLOCKED()

Now that the AioContext lock no longer exists, AIO_WAIT_WHILE() and
AIO_WAIT_WHILE_UNLOCKED() are equivalent.

A future patch will get rid of AIO_WAIT_WHILE_UNLOCKED().

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-10-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 9f8d2fdcce78587b7861ac6b9d2c8bdc2bbb9ad4
      
https://github.com/qemu/qemu/commit/9f8d2fdcce78587b7861ac6b9d2c8bdc2bbb9ad4
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M include/block/aio.h
    M util/async.c

  Log Message:
  -----------
  aio: remove aio_context_acquire()/aio_context_release() API

Delete these functions because nothing calls these functions anymore.

I introduced these APIs in commit 98563fc3ec44 ("aio: add
aio_context_acquire() and aio_context_release()") in 2014. It's with a
sigh of relief that I delete these APIs almost 10 years later.

Thanks to Paolo Bonzini's vision for multi-queue QEMU, we got an
understanding of where the code needed to go in order to remove the
limitations that the original dataplane and the IOThread/AioContext
approach that followed it.

Emanuele Giuseppe Esposito had the splendid determination to convert
large parts of the codebase so that they no longer needed the AioContext
lock. This was a painstaking process, both in the actual code changes
required and the iterations of code review that Emanuele eked out of
Kevin and me over many months.

Kevin Wolf tackled multitudes of graph locking conversions to protect
in-flight I/O from run-time changes to the block graph as well as the
clang Thread Safety Analysis annotations that allow the compiler to
check whether the graph lock is being used correctly.

And me, well, I'm just here to add some pizzazz to the QEMU multi-queue
block layer :). Thank you to everyone who helped with this effort,
including Eric Blake, code reviewer extraordinaire, and others who I've
forgotten to mention.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-11-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: e0444c276a6bbd0300a76bea768f89d5dbfec3e8
      
https://github.com/qemu/qemu/commit/e0444c276a6bbd0300a76bea768f89d5dbfec3e8
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M docs/devel/multiple-iothreads.txt

  Log Message:
  -----------
  docs: remove AioContext lock from IOThread docs

Encourage the use of locking primitives and stop mentioning the
AioContext lock since it is being removed.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-12-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: e7fc3c4a8cc3e729d178b95721d51ca95573ba91
      
https://github.com/qemu/qemu/commit/e7fc3c4a8cc3e729d178b95721d51ca95573ba91
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

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

  Log Message:
  -----------
  scsi: remove outdated AioContext lock comment

The SCSI subsystem no longer uses the AioContext lock. Request
processing runs exclusively in the BlockBackend's AioContext since
"scsi: only access SCSIDevice->requests from one thread" and hence the
lock is unnecessary.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-13-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: e91083cd3f082c4d26a7d52268cbd57fc81def28
      
https://github.com/qemu/qemu/commit/e91083cd3f082c4d26a7d52268cbd57fc81def28
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M include/qemu/job.h

  Log Message:
  -----------
  job: remove outdated AioContext locking comments

The AioContext lock no longer exists.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-14-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 23c983c8f6b2fea22698f501aa6a2c03dadd81ba
      
https://github.com/qemu/qemu/commit/23c983c8f6b2fea22698f501aa6a2c03dadd81ba
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block.c
    M block/block-backend.c
    M block/export/vhost-user-blk-server.c
    M include/block/block-common.h
    M include/block/block-io.h
    M include/block/block_int-common.h
    M tests/qemu-iotests/202
    M tests/qemu-iotests/203

  Log Message:
  -----------
  block: remove outdated AioContext locking comments

The AioContext lock no longer exists.

There is one noteworthy change:

  - * More specifically, these functions use BDRV_POLL_WHILE(bs), which
  - * requires the caller to be either in the main thread and hold
  - * the BlockdriverState (bs) AioContext lock, or directly in the
  - * home thread that runs the bs AioContext. Calling them from
  - * another thread in another AioContext would cause deadlocks.
  + * More specifically, these functions use BDRV_POLL_WHILE(bs), which requires
  + * the caller to be either in the main thread or directly in the home thread
  + * that runs the bs AioContext. Calling them from another thread in another
  + * AioContext would cause deadlocks.

I am not sure whether deadlocks are still possible. Maybe they have just
moved to the fine-grained locks that have replaced the AioContext. Since
I am not sure if the deadlocks are gone, I have kept the substance
unchanged and just removed mention of the AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231205182011.1976568-15-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: c12887e1b087e8f69d217ccae3dc7b1d059f3db3
      
https://github.com/qemu/qemu/commit/c12887e1b087e8f69d217ccae3dc7b1d059f3db3
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M scripts/block-coroutine-wrapper.py

  Log Message:
  -----------
  block-coroutine-wrapper: use qemu_get_current_aio_context()

Use qemu_get_current_aio_context() in mixed wrappers and coroutine
wrappers so that code runs in the caller's AioContext instead of moving
to the BlockDriverState's AioContext. This change is necessary for the
multi-queue block layer where any thread can call into the block layer.

Most wrappers are IO_CODE where it's safe to use the current AioContext
nowadays. BlockDrivers and the core block layer use their own locks and
no longer depend on the AioContext lock for thread-safety.

The bdrv_create() wrapper invokes GLOBAL_STATE code. Using the current
AioContext is safe because this code is only called with the BQL held
from the main loop thread.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230912231037.826804-6-stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: ff32bb53476539d352653f4ed56372dced73a388
      
https://github.com/qemu/qemu/commit/ff32bb53476539d352653f4ed56372dced73a388
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M include/qapi/string-output-visitor.h
    M qapi/string-output-visitor.c

  Log Message:
  -----------
  string-output-visitor: show structs as "<omitted>"

StringOutputVisitor crashes when it visits a struct because
->start_struct() is NULL.

Show "<omitted>" instead of crashing. This is necessary because the
virtio-blk-pci iothread-vq-mapping parameter that I'd like to introduce
soon is a list of IOThreadMapping structs.

This patch is a quick fix to solve the crash, but the long-term solution
is replacing StringOutputVisitor with something that can handle the full
gamut of values in QEMU.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231212134934.500289-1-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 350147a871a545ab56b4a1062c8485635d9ffc24
      
https://github.com/qemu/qemu/commit/350147a871a545ab56b4a1062c8485635d9ffc24
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/core/qdev-properties.c
    M include/hw/qdev-properties.h

  Log Message:
  -----------
  qdev-properties: alias all object class properties

qdev_alias_all_properties() aliases a DeviceState's qdev properties onto
an Object. This is used for VirtioPCIProxy types so that --device
virtio-blk-pci has properties of its embedded --device virtio-blk-device
object.

Currently this function is implemented using qdev properties. Change the
function to use QOM object class properties instead. This works because
qdev properties create QOM object class properties, but it also catches
any QOM object class-only properties that have no qdev properties.

This change ensures that properties of devices are shown with --device
foo,\? even if they are QOM object class properties.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231220134755.814917-2-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: cf03a152c5d749fd0083bfe540df9524f1d2ff1d
      
https://github.com/qemu/qemu/commit/cf03a152c5d749fd0083bfe540df9524f1d2ff1d
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/core/qdev-properties-system.c
    M include/hw/qdev-properties-system.h
    M qapi/virtio.json

  Log Message:
  -----------
  qdev: add IOThreadVirtQueueMappingList property type

virtio-blk and virtio-scsi devices will need a way to specify the
mapping between IOThreads and virtqueues. At the moment all virtqueues
are assigned to a single IOThread or the main loop. This single thread
can be a CPU bottleneck, so it is necessary to allow finer-grained
assignment to spread the load.

Introduce DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST() so devices can take a
parameter that maps virtqueues to IOThreads. The command-line syntax for
this new property is as follows:

  --device 
'{"driver":"foo","iothread-vq-mapping":[{"iothread":"iothread0","vqs":[0,1,2]},...]}'

IOThreads are specified by name and virtqueues are specified by 0-based
index.

It will be common to simply assign virtqueues round-robin across a set
of IOThreads. A convenient syntax that does not require specifying
individual virtqueue indices is available:

  --device 
'{"driver":"foo","iothread-vq-mapping":[{"iothread":"iothread0"},{"iothread":"iothread1"},...]}'

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231220134755.814917-4-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: b6948ab01df068bef591868c22d1f873d2d05cde
      
https://github.com/qemu/qemu/commit/b6948ab01df068bef591868c22d1f873d2d05cde
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M hw/block/dataplane/virtio-blk.c
    M hw/block/dataplane/virtio-blk.h
    M hw/block/virtio-blk.c
    M include/hw/virtio/virtio-blk.h

  Log Message:
  -----------
  virtio-blk: add iothread-vq-mapping parameter

Add the iothread-vq-mapping parameter to assign virtqueues to IOThreads.
Store the vq:AioContext mapping in the new struct
VirtIOBlockDataPlane->vq_aio_context[] field and refactor the code to
use the per-vq AioContext instead of the BlockDriverState's AioContext.

Reimplement --device virtio-blk-pci,iothread= and non-IOThread mode by
assigning all virtqueues to the IOThread and main loop's AioContext in
vq_aio_context[], respectively.

The comment in struct VirtIOBlockDataPlane about EventNotifiers is
stale. Remove it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231220134755.814917-5-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 6370d13c62c300826f8eb80e4ed9d2e67bad3fa7
      
https://github.com/qemu/qemu/commit/6370d13c62c300826f8eb80e4ed9d2e67bad3fa7
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M block.c
    M block/backup.c
    M block/blklogwrites.c
    M block/blkverify.c
    M block/block-backend.c
    M block/commit.c
    M block/copy-before-write.c
    M block/export/export.c
    M block/export/vhost-user-blk-server.c
    M block/file-posix.c
    M block/graph-lock.c
    M block/io.c
    M block/mirror.c
    M block/monitor/bitmap-qmp-cmds.c
    M block/monitor/block-hmp-cmds.c
    M block/qapi-sysemu.c
    M block/qapi.c
    M block/qcow2.c
    M block/quorum.c
    M block/raw-format.c
    M block/replication.c
    M block/snapshot.c
    M block/stream.c
    M block/vmdk.c
    M block/write-threshold.c
    M blockdev.c
    M blockjob.c
    M docs/devel/multiple-iothreads.txt
    M hw/block/dataplane/virtio-blk.c
    M hw/block/dataplane/virtio-blk.h
    M hw/block/dataplane/xen-block.c
    M hw/block/virtio-blk.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev-properties.c
    M hw/scsi/scsi-bus.c
    M hw/scsi/scsi-disk.c
    M hw/scsi/scsi-generic.c
    M hw/scsi/virtio-scsi-dataplane.c
    M hw/scsi/virtio-scsi.c
    M include/block/aio-wait.h
    M include/block/aio.h
    M include/block/block-common.h
    M include/block/block-global-state.h
    M include/block/block-io.h
    M include/block/block_int-common.h
    M include/block/graph-lock.h
    M include/block/snapshot.h
    M include/hw/qdev-properties-system.h
    M include/hw/qdev-properties.h
    M include/hw/scsi/scsi.h
    M include/hw/virtio/virtio-blk.h
    M include/hw/virtio/virtio-scsi.h
    M include/qapi/string-output-visitor.h
    M include/qemu/job.h
    M job.c
    M migration/block.c
    M migration/migration-hmp-cmds.c
    M migration/savevm.c
    M nbd/server.c
    M net/colo-compare.c
    M qapi/string-output-visitor.c
    M qapi/virtio.json
    M qemu-img.c
    M qemu-io.c
    M qemu-nbd.c
    M replay/replay-debugging.c
    M scripts/block-coroutine-wrapper.py
    M system/dma-helpers.c
    M system/vl.c
    M tests/qemu-iotests/202
    M tests/qemu-iotests/203
    A tests/qemu-iotests/tests/qcow2-internal-snapshots
    A tests/qemu-iotests/tests/qcow2-internal-snapshots.out
    M tests/tsan/suppressions.tsan
    M tests/unit/test-aio.c
    M tests/unit/test-bdrv-drain.c
    M tests/unit/test-bdrv-graph-mod.c
    M tests/unit/test-block-iothread.c
    M tests/unit/test-blockjob.c
    M tests/unit/test-replication.c
    M util/async.c
    M util/vhost-user-server.c

  Log Message:
  -----------
  Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging

Block layer patches

- virtio-blk: Multiqueue support (configurable iothread per queue)
- Made NBD export and hw/scsi thread-safe without AioContext lock
- Fix crash when loading snapshot on inactive node

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmWEw/8RHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9bX0Q/9G+Qx8mQGmbxJzvtW7/1eaeJ5CPCYT8w3
# 033S5hCil43mvX2aQKTFrh1Nz4aYlqMDyURvNu7nigyADY+kBpzzJ1MFr6WQrzYv
# QEk4jf/FOllfKn8+/A0z2NJDhtpVgqKKHBsFZl8FBUcxd79daTaoPPM3BNNsOHQD
# o7Z7hR/iEdG9dkAh/fpwctsgMO/CoN0BRRyN2OByj03zeu1TlDJ6lX0hxlcJl9Jw
# vLo81rWTCqKRu+SbjBsb0HfYE2hP54A4hvxn4I9vYGYDz8ElucluYyeqUEK+mdrX
# /DQBdb+Osl1FD6MuIaFR+Rgp9Mu5h6ZOdvUyCY0zuByti851hV8qjW9BtrTfqaMh
# LMOKoL6c5B8XJYWVGAGrJexIw1hHq5WKdXN9zp4FZA4tOyHUMRjHuR1+zScU6gnU
# WRSIQR46w75A13clWyJs9Hf/q5Fp/1KT4nfuZ/hmiXvxdsYY5x1w/W3s9tRNjYKL
# d6FVk17cFc6Ksb7lWvDCgg61BNZtGm4Clmw0kJ6V1reiQz7AvDLmduLUQbmrVt7G
# gWAY4b2L9YXJpEx5en0kE50KLAUw/E9ozbOq6ZT9nFUKeNAPC8PS5lK7vYVwebCk
# VA0t8pFzKhdB1bJaG5fMSRPBuqkvhsaDEEDABlSro8dyyjoQBaEdk5P9Kxe66hBc
# xhTmDPdv/JM=
# =E3Zh
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 21 Dec 2023 18:02:23 EST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://repo.or.cz/qemu/kevin: (33 commits)
  virtio-blk: add iothread-vq-mapping parameter
  qdev: add IOThreadVirtQueueMappingList property type
  qdev-properties: alias all object class properties
  string-output-visitor: show structs as "<omitted>"
  block-coroutine-wrapper: use qemu_get_current_aio_context()
  block: remove outdated AioContext locking comments
  job: remove outdated AioContext locking comments
  scsi: remove outdated AioContext lock comment
  docs: remove AioContext lock from IOThread docs
  aio: remove aio_context_acquire()/aio_context_release() API
  aio-wait: draw equivalence between AIO_WAIT_WHILE() and 
AIO_WAIT_WHILE_UNLOCKED()
  scsi: remove AioContext locking
  block: remove bdrv_co_lock()
  block: remove AioContext locking
  graph-lock: remove AioContext locking
  aio: make aio_context_acquire()/aio_context_release() a no-op
  tests: remove aio_context_acquire() tests
  scsi: assert that callbacks run in the correct AioContext
  virtio-scsi: replace AioContext lock with tmf_bh_lock
  dma-helpers: don't lock AioContext in dma_blk_cb()
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: 80f1709aa0eb4de09b4240563463f991a5b9d855
      
https://github.com/qemu/qemu/commit/80f1709aa0eb4de09b4240563463f991a5b9d855
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M include/hw/loongarch/virt.h
    M target/loongarch/cpu.c

  Log Message:
  -----------
  Merge tag 'pull-loongarch-20231221' of https://gitlab.com/gaosong/qemu into 
staging

pull-loongarch-20231221

# -----BEGIN PGP SIGNATURE-----
#
# iLMEAAEKAB0WIQS4/x2g0v3LLaCcbCxAov/yOSY+3wUCZYPyvQAKCRBAov/yOSY+
# 38/vBADT3b+Wo/2AeXOO3OXOM1VBhIvzDjY1OWytuJpkF3JGW45cMLqgtIgMj8h7
# NtzRS3JbFYbYuxITeeo1Ppl6dAD0pCZjIU6OCBxAJ6ADPsE/xD8nYWrMGqYVXg7E
# hN0Cno2sf6dmJ0QxUxn7G+cUuvNtnGaDSZE+RAkjtzq1nvx7CQ==
# =mte5
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 21 Dec 2023 03:09:33 EST
# gpg:                using RSA key B8FF1DA0D2FDCB2DA09C6C2C40A2FFF239263EDF
# gpg: Good signature from "Song Gao <m17746591750@163.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: B8FF 1DA0 D2FD CB2D A09C  6C2C 40A2 FFF2 3926 3EDF

* tag 'pull-loongarch-20231221' of https://gitlab.com/gaosong/qemu:
  target/loongarch: Add timer information dump support
  hw/loongarch/virt: Align high memory base address with super page size

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


Compare: https://github.com/qemu/qemu/compare/6b034f6960b1...80f1709aa0eb



reply via email to

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