Unmapping a blob changes the memory map, which is protected with RCU.
RCU is designed to minimize the read-side overhead at the cost of
reclamation delay. While this design usually makes sense, it is
problematic when unmapping a blob because the operation blocks all
virtio-gpu commands and causes perceivable disruption.
Minimize such the disruption with force_rcu(), which minimizes the
reclamation delay at the cost of a read-side overhead.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v3:
- Fix immediate timeout in qemu_futex_timedwait() for Windows.
- Dropped patch "timer: Rename init_clocks() to qemu_clock_init()".
- Link to v2: https://lore.kernel.org/qemu-devel/20251213-force_rcu-v2-0-1de1ca84c6d6@rsg.ci.i.u-tokyo.ac.jp
Changes in v2:
- Stopped overloading the call_rcu1() and force_rcu() notifications onto
one event. This fixes a deadlock after try_dequeue() caused by
incorrect masking of call_rcu1() notifications, and eliminates
spurious force quiescent states caused by being confused with a
call_rcu1() notification.
Tested-by: from the previous version was not collected because this
changes the logic significantly.
- Merged the rcu_call_count and forced variables into one to avoid
the race between them that used to require a loop to resolve.
- Aligned the type of the duration variable in qemu_futex_timedwait()
for Windows.
- Fixed timespec of qemu_futex_timedwait() for 32-bit Linux.
- Link to v1: https://lore.kernel.org/qemu-devel/20251029-force_rcu-v1-0-bf860a6277a6@rsg.ci.i.u-tokyo.ac.jp
---
Akihiko Odaki (5):
futex: Add qemu_futex_timedwait()
qemu-thread: Add qemu_event_timedwait()
rcu: Use call_rcu() in synchronize_rcu()
rcu: Wake the RCU thread when draining
virtio-gpu: Force RCU when unmapping blob
include/qemu/futex.h | 36 +++++++++++++---
include/qemu/rcu.h | 1 +
include/qemu/thread-posix.h | 11 +++++
include/qemu/thread.h | 8 +++-
hw/display/virtio-gpu-virgl.c | 1 +
util/event.c | 28 ++++++++++---
util/qemu-thread-posix.c | 11 +----
util/rcu.c | 98 ++++++++++++++++++++++++-------------------
8 files changed, 131 insertions(+), 63 deletions(-)
---
base-commit: fba5c49719875145f1dcb44fbe85f541a47805c6
change-id: 20251027-force_rcu-616c743373f7
Best regards,
--
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>