[PATCH] virtio-blk: support polling I/O

Michael S. Tsirkin
Mon, 14 Mar 2022 22:22:19 -0000

On Mon, Mar 14, 2022 at 06:33:06PM +0200, Max Gurtovoy
wrote:
>
> On 3/14/2022 5:15 PM, Michael S. Tsirkin wrote:
> > On Mon, Mar 14, 2022 at 03:26:13PM +0200, Max Gurtovoy wrote:
> > > On 3/14/2022 1:15 PM, Michael S. Tsirkin wrote:
> > > > On Mon, Mar 14, 2022 at 12:25:08PM +0200, Max Gurtovoy
wrote:
> > > > > On 3/14/2022 11:43 AM, Suwan Kim wrote:
> > > > > > On Sun, Mar 13, 2022 at 12:37:21PM +0200, Max
Gurtovoy wrote:
> > > > > > > On 3/11/2022 6:07 PM, Suwan Kim wrote:
> > > > > > > > On Fri, Mar 11, 2022 at 10:38:07AM
-0500, Michael S. Tsirkin wrote:
> > > > > > > > > On Sat, Mar 12, 2022 at 12:28:32AM
+0900, Suwan Kim wrote:
> > > > > > > > > > diff --git
a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h
> > > > > > > > > > index
d888f013d9ff..3fcaf937afe1 100644
> > > > > > > > > > ---
a/include/uapi/linux/virtio_blk.h
> > > > > > > > > > +++
b/include/uapi/linux/virtio_blk.h
> > > > > > > > > > @@ -119,8 +119,9 @@ struct
virtio_blk_config {
> > > > > > > > > >      	 * deallocation of one
or more of the sectors.
> > > > > > > > > >      	 */
> > > > > > > > > >      	__u8
write_zeroes_may_unmap;
> > > > > > > > > > +	__u8 unused1;
> > > > > > > > > > -	__u8 unused1[3];
> > > > > > > > > > +	__virtio16 num_poll_queues;
> > > > > > > > > >      }
__attribute__((packed));
> > > > > > > > > Same as any virtio UAPI change,
this has to go through the virtio TC.
> > > > > > > > > In particular I don't think
gating a new config field on
> > > > > > > > > an existing feature flag is a good
idea.
> > > > > > > > Did you mean that the polling should be
based on a new feature like
> > > > > > > > "VIRTIO_BLK_F_POLL" and be
added at the end of features_legacy[]
> > > > > > > > and features[]? If then, I will add the
new feture flag and resend it.
> > > > > > > Isn't there a way in the SPEC today to
create a queue without interrupt
> > > > > > > vector ?
> > > > > > It seems that it is not possible to create a queue
without interrupt
> > > > > > vector. If it is possible, we can expect more
polling improvement.
> > > > Yes, it's possible:
> > > >
> > > > Writing a valid MSI-X Table entry number, 0 to 0x7FF, to
> > > > \field{config_msix_vector}/\field{queue_msix_vector} maps
interrupts triggered
> > > > by the configuration change/selected queue events
respectively to
> > > > the corresponding MSI-X vector. To disable interrupts for an
> > > > event type, the driver unmaps this event by writing a
special NO_VECTOR
> > > > value:
> > > >
> > > > \begin{lstlisting}
> > > > /* Vector value used to disable MSI for queue */
> > > > #define VIRTIO_MSI_NO_VECTOR            0xffff
> > > > \end{lstlisting}
> > > >
> > > >
> > > >
> > > > > MST/Jason/Stefan,
> > > > >
> > > > > can you confirm that please ?
> > > > >
> > > > > what does VIRTQ_AVAIL_F_NO_INTERRUPT supposed to do ?
> > > > This is a hint to the device not to send interrupts.
> > > Why do you need a hint if the driver implicitly wrote 0xffff to
disable MSI
> > > for a virtqueue ?
> >
> > VIRTIO_MSI_NO_VECTOR is an expensive write into config space, followed
> > by an even more expensive read. Reliable and appropriate if you turn
> > events on/off very rarely.
> >
> > VIRTQ_AVAIL_F_NO_INTERRUPT is an in-memory write so it's much
cheaper,
> > but it's less reliable. Appropriate if you need to turn events
on/off a
> > lot.
>
> An "expensive" operation in the ctrl path during vq creation is
fine IMO.

Yes.

> I see that nobody even used VIRTQ_AVAIL_F_NO_INTERRUPT in-memory write in
> Linux.

Because it's called VRING_AVAIL_F_NO_INTERRUPT there.

> >
> >
> > > > > > Regards,
> > > > > > Suwan Kim