libqos: use microseconds instead of iterations for virtio timeout
PATCH 1/1 libqos: use microseconds instead of iterations for virtio timeout
Some hosts are slow or overloaded so test execution takes a long time. Test cases use timeouts to protect against an infinite loop stalling the test forever (especially important in automated test setups).
Commit 6cd14054b67774cc58a51fca6660cfa1d3c08059 ("libqos virtio:
Increase ISR timeout") increased the clock_step() value in an attempt to lengthen the virtio interrupt wait timeout, but timeout failures are still occuring on the Travis automated testing platform.
This is because clock_step() only affects the guest's virtual time. Virtio requests can be bottlenecked on host disk I/O latency - which cannot be improved by stepping the clock, so the fix was ineffective.
This patch changes the qvirtio_wait_queue_isr() and qvirtio_wait_config_isr() timeout mechanism from loop iterations to microseconds. This way the test case can specify an absolute 30 second timeout. Number of loop iterations is not a reliable timeout mechanism since the speed depends on many factors including host performance.
Tests should no longer timeout on overloaded Travis instances.
Note that I dropped an assertion that waits for the full timeout duration to assert that no interrupt was raised. I think this is not a huge loss because it makes the test case non-deterministic (it cannot really prove the no interrupt will ever be raised).
--- tests/libqos/virtio.c | 30 +++++++++++++++------------- tests/libqos/virtio.h | 8 ++++---- tests/virtio-blk-test.c | 52 ++++++++++++++++++++++--------------------------- 3 files changed, 43 insertions(+), 47 deletions(-)
tests/libqos/virtio.c +16 -14
@@ -78,30 +78,32 @@ void qvirtio_set_driver_ok(const QVirtioBus *bus, QVirtioDevice *d) QVIRTIO_DRIVER_OK | QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE); } -bool qvirtio_wait_queue_isr (const QVirtioBus *bus,QVirtioDevice *d, -QVirtQueue *vq,uint64_t timeout) +void qvirtio_wait_queue_isr (const QVirtioBus *bus,QVirtioDevice *d, +QVirtQueue *vq,gint64 timeout_us) { -do { +gint64 start_time =g_get_monotonic_time (); + +for (;;) {clock_step (100 );if (bus->get_queue_isr_status (d, vq)) { -break ;/* It has ended */ +return ; } - }while (--timeout); - -return timeout !=0 ; +g_assert (g_get_monotonic_time () - start_time <= timeout_us); + } } -bool qvirtio_wait_config_isr (const QVirtioBus *bus,QVirtioDevice *d, -uint64_t timeout) +void qvirtio_wait_config_isr (const QVirtioBus *bus,QVirtioDevice *d, +gint64 timeout_us) { -do { +gint64 start_time =g_get_monotonic_time (); + +for (;;) {clock_step (100 );if (bus->get_config_isr_status (d)) { -break ;/* It has ended */ +return ; } - }while (--timeout); - -return timeout !=0 ; +g_assert (g_get_monotonic_time () - start_time <= timeout_us); + } }void qvring_init (const QGuestAllocator *alloc,QVirtQueue *vq,uint64_t addr)
tests/libqos/virtio.h +4 -4
@@ -160,10 +160,10 @@ void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d);void qvirtio_set_driver (const QVirtioBus *bus,QVirtioDevice *d);void qvirtio_set_driver_ok (const QVirtioBus *bus,QVirtioDevice *d); -bool qvirtio_wait_queue_isr (const QVirtioBus *bus,QVirtioDevice *d, -QVirtQueue *vq,uint64_t timeout); -bool qvirtio_wait_config_isr (const QVirtioBus *bus,QVirtioDevice *d, -uint64_t timeout); +void qvirtio_wait_queue_isr (const QVirtioBus *bus,QVirtioDevice *d, +QVirtQueue *vq,gint64 timeout_us); +void qvirtio_wait_config_isr (const QVirtioBus *bus,QVirtioDevice *d, +gint64 timeout_us);QVirtQueue *qvirtqueue_setup (const QVirtioBus *bus,QVirtioDevice *d,QGuestAllocator *alloc,uint16_t index);
tests/virtio-blk-test.c +23 -29
136 lines not on this page · raw message
Signature · 1 line
1.9.3
Quoted 19 lines · Stefan Hajnoczi
Some hosts are slow or overloaded so test execution takes a long time. Test cases use timeouts to protect against an infinite loop stalling the test forever (especially important in automated test setups).
Commit
6cd14054b67774cc58a51fca6660cfa1d3c08059("libqos virtio:
Increase ISR timeout") increased theclock_step()value in an attempt to lengthen the virtio interrupt wait timeout, but timeout failures are still occuring on the Travis automated testing platform.This is because
clock_step()only affects the guest's virtual time. Virtio requests can be bottlenecked on host disk I/O latency - which cannot be improved by stepping the clock, so the fix was ineffective.This patch changes the
qvirtio_wait_queue_isr()andqvirtio_wait_config_isr()timeout mechanism from loop iterations to microseconds. This way the test case can specify an absolute 30 second timeout. Number of loop iterations is not a reliable timeout mechanism since the speed depends on many factors including host performance.
Quoted 6 lines
Tests should no longer timeout on overloaded Travis instances.
Note that I dropped an assertion that waits for the full timeout duration to assert that no interrupt was raised. I think this is not a huge loss because it makes the test case non-deterministic (it cannot really prove the no interrupt will ever be raised).
As per IRC conversation, this patch causes 'make check' to fail on some (slower?) systems with:
ERROR:/home/petmay01/linaro/qemu-for-merges/tests/virtio-blk-test.c:596:pci_idx:
assertion failed (status == 0): (255 == 0)
Stefan has diagnosed this as a failure to poll for the zero status code, and is working on a patch.
-- PMM