[dpdk-dev] [PATCH v5 0/4] Vhost: fix mq=on but VIRTIO_NET_F_MQ not negotiated

Maxime Coquelin maxime.coquelin at redhat.com
Wed Dec 13 11:11:04 CET 2017


Hi Paolo,

On 12/13/2017 10:15 AM, Paolo Bonzini wrote:
> On 13/12/2017 09:51, Maxime Coquelin wrote:
>> This series fixes this by destroying all but first queue pair in
>> the backend if VIRTIO_NET_F_MQ isn't negotiated. First patches
>> makes sure that VHOST_USER_SET_FEATURES request doesn't change
>> Virtio features while the device is running, which should never
>> happen as per the Virtio spec. This helps to make sure vitqueues
>> aren't destroyed while being processed, but also protect from
>> other illegal features changes (e.g. VIRTIO_NET_F_MRG_RXBUF).
> 
> Hi Maxime,
> 
> I think this series is wrong from the virtio spec's point of view.  If
> the driver requests VIRTIO_NET_F_MQ, that does not mean "the driver
> knows about multiqueue", it only means that "the driver wants to read
> max_virtqueue_pairs" from configuration space.

Actually, my series fixes half of the problem, the case where driver
does not know about multiqueue.

In this case, there is no point in the backend to wait for the
initialization of queues that does not exist.

So I think my series is not enough, but not wrong.

> Just like it's perfectly fine for a device to propose VIRTIO_NET_F_MQ
> and set max_virtqueue_pairs=1, a driver can negotiate VIRTIO_NET_F_MQ
> and then skip initialization of some virtqueues.
> 
> In fact, for virtio-net there is an explicit way to say how many
> virtqueue pairs are available; the virtio spec's section 5.1.5 (Network
> device, Device Initialization) mentions that
> 
> 	Even with VIRTIO_NET_F_MQ, only receiveq1, transmitq1 and
> 	controlq are used by default. The driver would send the
> 	VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command specifying the number of
> 	the transmit and receive queues to use.

Yes, I agree.

I was planning to send a vhost-user protocol spec update to forward this 
information to the backend with a new request.

Currently, DPDK will increment the queue counter each time it receives a
request for a new queue. Then it waits for all queues to be initialized
(but not necessarily enabled) to start the vhost device.

The problem is that QEMU, when receiving the 
VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command, will send
VHOST_USER_SET_VRING_ENABLE request to the backend to enable first queue
pair, and disable all others.

We cannot destroy a queue on disable, because it could happen in other
cases, where it would be re-enabled without being re-initialized.

So on DPDK side, my understanding is that we cannot deduce the number of
queues that we have to wait to be initialized before starting the
device. DPDK currently assume a queue to be initialized if rings 
addresses are set and if it has received both call and kick fds.

I only fixed half of the problem as a first step because current Kernel 
& DPDK virtio-net drivers always allocate the maximum number of queues
exposed by QEMU, even if it does use them all. But it is not compliant 
with the Virtio spec, which does not imply this (and the spec is right).

Thanks,
Maxime

> Thanks,
> 
> Paolo
> 


More information about the dev mailing list