mirror of https://gitlab.com/qemu-project/qemu
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls. Background ========== The previous implementation had four steps to begin reclamation. 1. call_rcu_thread() would wait for the first callback. 2. call_rcu_thread() would periodically poll until a decent number of callbacks piled up or it timed out. 3. synchronize_rcu() would statr a grace period (GP). 4. wait_for_readers() would wait for the GP to end. It would also trigger the force_rcu notifier to break busy loops in a read-side critical section if drain_call_rcu() had been called. Problem ======= The separation of waiting logic across these steps led to suboptimal behavior: The GP was delayed until call_rcu_thread() stops polling. force_rcu was not consistently triggered when call_rcu_thread() detected a high number of pending callbacks or a timeout. This inconsistency sometimes led to stalls, as reported in a virtio-gpu issue where memory unmapping was blocked[1]. wait_for_readers() imposed unnecessary overhead in non-urgent cases by unconditionally executing qatomic_set(&index->waiting, true) and qemu_event_reset(&rcu_gp_event), which are necessary only for expedited synchronization. Solution ======== Move the polling in call_rcu_thread() to wait_for_readers() to prevent the delay of the GP. Additionally, reorganize wait_for_readers() to distinguish between two states: Normal State: it relies exclusively on periodic polling to detect the end of the GP and maintains the read-side fast path. Force Quiescent State: Whenever expediting synchronization, it always triggers force_rcu and executes both qatomic_set(&index->waiting, true) and qemu_event_reset(&rcu_gp_event). This avoids stalls while confining the read-side overhead to this state. This unified approach, inspired by the Linux RCU, ensures consistent and efficient RCU grace period handling and confirms resolution of the virtio-gpu issue. [1] https://lore.kernel.org/qemu-devel/20251014111234.3190346-9-alex.bennee@linaro.org/ Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Link: https://lore.kernel.org/r/20251016-force-v1-1-919a82112498@rsg.ci.i.u-tokyo.ac.jp Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
5 days ago | |
|---|---|---|
| .. | ||
| aio-posix.c | 8 months ago | |
| aio-posix.h | 8 months ago | |
| aio-wait.c | 3 years ago | |
| aio-win32.c | 1 month ago | |
| aiocb.c | ||
| async.c | 3 weeks ago | |
| atomic64.c | 4 years ago | |
| base64.c | 5 years ago | |
| bitmap.c | 3 years ago | |
| bitops.c | 3 years ago | |
| block-helpers.c | 1 year ago | |
| block-helpers.h | 1 year ago | |
| buffer.c | 5 years ago | |
| bufferiszero.c | 1 year ago | |
| cacheflush.c | 2 weeks ago | |
| chardev_open.c | 2 years ago | |
| compatfd.c | 4 years ago | |
| coroutine-sigaltstack.c | 2 years ago | |
| coroutine-ucontext.c | 2 years ago | |
| coroutine-wasm.c | 6 months ago | |
| coroutine-windows.c | 2 years ago | |
| cpuinfo-aarch64.c | 1 year ago | |
| cpuinfo-i386.c | 2 months ago | |
| cpuinfo-loongarch.c | 1 year ago | |
| cpuinfo-ppc.c | 1 year ago | |
| cpuinfo-riscv.c | 10 months ago | |
| crc-ccitt.c | 5 years ago | |
| crc32c.c | 2 years ago | |
| cutils.c | 1 year ago | |
| dbus.c | 6 years ago | |
| defer-call.c | 2 years ago | |
| drm.c | 5 years ago | |
| envlist.c | 1 year ago | |
| error-report.c | 1 year ago | |
| error.c | 1 month ago | |
| event.c | 5 months ago | |
| event_notifier-posix.c | 1 month ago | |
| event_notifier-win32.c | 4 years ago | |
| fdmon-epoll.c | 1 year ago | |
| fdmon-io_uring.c | 2 years ago | |
| fdmon-poll.c | 2 years ago | |
| fifo8.c | 1 year ago | |
| filemonitor-inotify.c | 2 years ago | |
| filemonitor-stub.c | 5 years ago | |
| getauxval.c | 1 year ago | |
| guest-random.c | 2 years ago | |
| hbitmap.c | 1 year ago | |
| hexdump.c | 8 months ago | |
| host-utils.c | 3 years ago | |
| id.c | 5 years ago | |
| int128.c | 3 years ago | |
| interval-tree.c | 2 years ago | |
| iov.c | 8 months ago | |
| iova-tree.c | 8 months ago | |
| keyval.c | 9 months ago | |
| lockcnt.c | 5 months ago | |
| log.c | 1 month ago | |
| main-loop.c | 1 month ago | |
| memalign.c | 4 years ago | |
| memfd.c | 9 months ago | |
| meson.build | 5 months ago | |
| mmap-alloc.c | 3 years ago | |
| module.c | 9 months ago | |
| notify.c | 2 years ago | |
| nvdimm-utils.c | 5 years ago | |
| osdep.c | 1 year ago | |
| oslib-posix.c | 4 weeks ago | |
| oslib-win32.c | 4 weeks ago | |
| path.c | 6 years ago | |
| qdist.c | 2 years ago | |
| qemu-co-shared-resource.c | 1 year ago | |
| qemu-co-timeout.c | 3 years ago | |
| qemu-config.c | 9 months ago | |
| qemu-coroutine-io.c | 2 years ago | |
| qemu-coroutine-lock.c | 2 years ago | |
| qemu-coroutine-sleep.c | 3 years ago | |
| qemu-coroutine.c | 1 year ago | |
| qemu-option.c | 9 months ago | |
| qemu-print.c | 5 years ago | |
| qemu-progress.c | 4 years ago | |
| qemu-sockets.c | 5 months ago | |
| qemu-thread-common.h | 7 years ago | |
| qemu-thread-posix.c | 5 months ago | |
| qemu-thread-win32.c | 5 months ago | |
| qemu-timer-common.c | 5 years ago | |
| qemu-timer.c | 3 weeks ago | |
| qht.c | 6 months ago | |
| qsp.c | 2 years ago | |
| qtree.c | 3 years ago | |
| range.c | 2 years ago | |
| rcu.c | 5 days ago | |
| readline.c | 1 year ago | |
| reserved-region.c | 2 years ago | |
| s390x_pci_mmio.c | 6 months ago | |
| selfmap.c | 2 years ago | |
| stats64.c | 3 years ago | |
| sys_membarrier.c | 8 years ago | |
| systemd.c | 3 years ago | |
| thread-context.c | 6 months ago | |
| thread-pool.c | 8 months ago | |
| throttle.c | 2 years ago | |
| timed-average.c | 1 year ago | |
| trace-events | 8 months ago | |
| trace.h | 5 years ago | |
| transactions.c | 4 years ago | |
| unicode.c | 7 years ago | |
| userfaultfd.c | 1 year ago | |
| uuid.c | 2 years ago | |
| vfio-helpers.c | 6 months ago | |
| vhost-user-server.c | 1 month ago | |
| yank.c | 2 years ago | |