Files
qemu/block
Alberto Garcia 9c8430f5d6 throttle-group: Fix race condition in throttle_group_restart_queue()
When a timer is fired a pending I/O request is restarted and
tg->any_timer_armed is reset so other requests can be scheduled.

However we're resetting any_timer_armed first in timer_cb() before
the request is actually restarted, and there's a window between both
moments in which another thread can arm the same timer, hitting an
assertion in throttle_group_restart_queue().

This can be solved by deferring the reset of tg->any_timer_armed to
the moment when the queue is actually restarted, which is protected by
tg->lock, preventing other threads from arming the timer before that.

In addition to that, throttle_group_restart_tgm() is also updated to
hold tg->lock while the timer is being inspected. Here we consider
three different scenarios:

- If the tgm has a timer set, fire it immediately
- If another tgm has a timer set, restart the queue anyway
- If there is no timer set in this group then simulate a timer that
  fires immediately, by setting tg->any_timer_armed in order to
  prevent other threads from arming a timer in the meantime.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3194
Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-Id: <825598ef34ad384d936da19d634eda75598508f7.1773316842.git.berto@igalia.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
2026-03-16 16:55:18 +01:00
..
2026-03-10 12:12:02 +01:00
2025-12-27 10:11:09 +01:00
2025-11-11 22:06:09 +01:00
2025-03-06 14:21:25 +01:00
2023-11-08 17:56:18 +01:00
2026-01-17 10:46:42 +11:00
2024-12-20 17:44:56 +01:00
2026-03-10 14:33:55 +01:00
2025-11-18 18:01:57 +01:00
2025-12-15 09:50:41 -05:00
2023-11-08 17:56:18 +01:00
2023-11-08 17:56:18 +01:00