Synchronous virtqueue interaction

Description

Virtio queues are fundamentally an asynchronous communication mechanism, with guest and host manipulating buffers on the virtqueue and then notifying the remote side.

During the implementation of , this turned into a significant limitation, as most in-kernel drivers using GPIO rely on interactions with the GPIO controller be synchronous, and get called from atomic context.

A similar problem has appeared earlier in , which works around the problem by busy-looping until a request is complete in order to be callable from atomic context.

An extension to the virtqueue design could solve this by having the host perform the entire transaction during the virtqueue notify hypercall, with the protocol requiring that all buffers associated with the transaction are returned to the guest immediately.

This is clearly a feature that has to be negotiated between guest and host, as no existing implementation can guarantee this behavior, and it may not be possible to implement on all device back-ends, nor on all hypervisors.

Activity

Bill Mills 
April 19, 2023 at 8:50 PM
(edited)

“having the host perform the entire transaction during the virtqueue notify hypercall, with the protocol requiring that all buffers associated with the transaction are returned to the guest immediately.”

“Immediately” is in the eye of the beholder. What that really means is that the VCPU freezes while the work gets done. This is not good for VCPU Real Time latency. With RT patch set this atomic context likly becomes a threaded interrupt and is preemptable by higher priority activities. So it is guest chocie to prioritize latency performance at the cost of greater overhead. If you take control in the Hypervisor to lose that choice.

For GPIO, the duration might not be that bad if implemented directly in the hypervisor but if the work is done by a driver domain or coprocessors it can take more time.

People use I2C and SPI GPIO expanders all the time. I view Virtio GPIO like that. Mark Brown may have thoughts I think he is still the maintainer of regmap.)

Alex Bennée 
April 19, 2023 at 3:22 PM

This may become relevant again with the HMP work under

Deferred

Details

Assignee

Reporter

Priority

Checklist

Sentry

Created August 12, 2021 at 8:37 AM
Updated April 19, 2023 at 8:52 PM
Resolved April 19, 2023 at 3:22 PM