Implement multiqueue virtio-net
Subsystems (6)
cover Implement multiqueue virtio-net
Following patches implement Transmit mq in virtio-net. Also included is the user qemu changes.
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
2. For this mq TX patch, 1 daemon is created for RX and 'n' daemons for the 'n' TXQ's, for a total of (n+1) daemons. The (subsequent) RX mq patch changes that to a total of 'n' daemons, where RX and TX vq's share 1 daemon.
3. Service Demand increases for TCP, but significantly improves for UDP.
4. Interoperability: Many combinations, but not all, of qemu, host, guest tested together.
Enabling mq on virtio:
-----------------------
When following options are passed to qemu:
- smp > 1
- vhost=on
- mq=on (new option, default:off)
then #txqueues = #cpus. The #txqueues can be changed by using an optional 'numtxqs' option. e.g. for a smp=4 guest:
vhost=on,mq=on -> #txqueues = 4
vhost=on,mq=on,numtxqs=8 -> #txqueues = 8
vhost=on,mq=on,numtxqs=2 -> #txqueues = 2 Performance (guest -> local host):
-----------------------------------System configuration:
Host: 8 Intel Xeon, 8 GB memory
Guest: 4 cpus, 2 GB memory
All testing without any tuning, and TCP netperf with 64K I/O
_______________________________________________________________________________
TCP (#numtxqs=2)
N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%)
_______________________________________________________________________________
4 26387 40716 (54.30) 20 28 (40.00) 86i 85 (-1.16)
8 24356 41843 (71.79) 88 129 (46.59) 372 362 (-2.68)
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519 (-2.50)
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722 (-14.52)
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552 (-14.35)
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173 (-9.66)
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031 (10.74)
_______________________________________________________________________________
UDP (#numtxqs=8)
N# BW1 BW2 (%) SD1 SD2 (%)
__________________________________________________________
4 29836 56761 (90.24) 67 63 (-5.97)
8 27666 63767 (130.48) 326 265 (-18.71)
16 25452 60665 (138.35) 1396 1269 (-9.09)
32 26172 63491 (142.59) 5617 4202 (-25.19)
48 26146 64629 (147.18) 12813 9316 (-27.29)
64 25575 65448 (155.90) 23063 16346 (-29.12)
128 26454 63772 (141.06) 91054 85051 (-6.59)__________________________________________________________
N#: Number of netperf sessions, 90 sec runs BW1,SD1,RSD1: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for original code
BW2,SD2,RSD2: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for new code. e.g. BW2=40716 means average BW2 was
20358 mbps.
Next steps:
-----------1. mq RX patch is also complete - plan to submit once TX is OK.
2. Cache-align data structures: I didn't see any BW/SD improvement after making the sq's (and similarly for vhost) cache-aligned statically:
struct virtnet_info {
...
struct send_queue sq[16] ____cacheline_aligned_in_smp;
...
};Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts
CPU0 CPU1 CPU2 CPU3
40: 0 0 0 0 PCI-MSI-edge virtio0-config
41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input
42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0
43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1
44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2
45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3Review/feedback appreciated.
---
RFC PATCH 1/4 Add a new API to virtio-pci
Add virtio_get_queue_index() to get the queue index of a vq. This is needed by the cb handler to locate the queue that should be processed.
--- drivers/virtio/virtio_pci.c | 9 +++++++++ include/linux/virtio.h | 3 +++ 2 files changed, 12 insertions(+)
include/linux/virtio.h +3 -0
@@ -136,4 +136,7 @@ struct virtio_driver {int register_virtio_driver (struct virtio_driver *drv);void unregister_virtio_driver (struct virtio_driver *drv); + +/* return the internal queue index associated with the virtqueue */ +extern int virtio_get_queue_index (struct virtqueue *vq);#endif /* _LINUX_VIRTIO_H */
drivers/virtio/virtio_pci.c +9 -0
@@ -359,6 +359,15 @@ static int vp_request_intx(struct virtioreturn err; } +/* Return the internal queue index associated with the virtqueue */ +int virtio_get_queue_index (struct virtqueue *vq) +{ +struct virtio_pci_vq_info *info = vq->priv; + +return info->queue_index; +} +EXPORT_SYMBOL (virtio_get_queue_index); + static struct virtqueue *setup_vq(struct virtio_device *vdev, unsigned index, void (*callback)(struct virtqueue *vq), const char *name,
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 3 lines · Krishna Kumar
Add
virtio_get_queue_index()to get the queue index of a vq. This is needed by the cb handler to locate the queue that should be processed.
This seems a bit weird. I mean, the driver used vdev->config->find_vqs to find the queues, which returns them (in order). So, can't you put this into your struct send_queue?
Also, why define VIRTIO_MAX_TXQS? If the driver can't handle all of them, it should simply not use them...
Thanks!
Rusty.
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Rusty Russell <[email protected]> wrote on 09/09/2010 09:19:39 AM:
Quoted 7 lines · Krishna Kumar
Quoted 3 lines
Add
virtio_get_queue_index()to get the queue index of a vq. This is needed by the cb handler to locate the queue that should be processed.This seems a bit weird. I mean, the driver used
vdev->config->find_vqsto find the queues, which returns them (in order). So, can't you put
this
Quoted 1 line
into your struct
send_queue?
I am saving the vqs in the send_queue, but the cb needs to locate the device txq from the svq. The only other way I could think of is to iterate through the send_queue's and compare svq against sq[i]->svq, but cb's happen quite a bit. Is there a better way?
static void skb_xmit_done(struct virtqueue *svq)
{
struct virtnet_info *vi = svq->vdev->priv;
int qnum = virtio_get_queue_index(svq) - 1; /* 0 is RX vq */
/* Suppress further interrupts. */
virtqueue_disable_cb(svq);
/* We were probably waiting for more output buffers. */
netif_wake_subqueue(vi->dev, qnum);
}Quoted 1 line
Also, why define
VIRTIO_MAX_TXQS? If the driver can't handle all of
them,
Quoted 1 line
it should simply not use them...
The main reason was vhost :) Since vhost_net_release should not fail (__fput can't handle f_op->release() failure), I needed a maximum number of socks to clean up:
#define MAX_VQS (1 + VIRTIO_MAX_TXQS)
static int vhost_net_release(struct inode *inode, struct file *f)
{
struct vhost_net *n = f->private_data;
struct vhost_dev *dev = &n->dev;
struct socket *socks[MAX_VQS];
int i;
vhost_net_stop(n, socks);
vhost_net_flush(n);
vhost_dev_cleanup(dev);
for (i = n->dev.nvqs - 1; i >= 0; i--)
if (socks[i])
fput(socks[i]->file);
...
}Thanks,
- KK
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 9 lines · On Thu, 9 Sep 2010 02:53:52 pm Krishna Kumar2 wrote:
Rusty Russell <[email protected]> wrote on 09/09/2010 09:19:39 AM:
Quoted 7 lines · Krishna Kumar
Quoted 3 lines
Add
virtio_get_queue_index()to get the queue index of a vq. This is needed by the cb handler to locate the queue that should be processed.This seems a bit weird. I mean, the driver used
vdev->config->find_vqsto find the queues, which returns them (in order). So, can't you put
Quoted 8 lines
this
Quoted 1 line
into your struct
send_queue?I am saving the vqs in the
send_queue, but the cb needs to locate the device txq from the svq. The only other way I could think of is to iterate through the send_queue's and compare svq against sq[i]->svq, but cb's happen quite a bit. Is there a better way?
Ah, good point. Move the queue index into the struct virtqueue?
Quoted 8 lines
Quoted 1 line
Also, why define
VIRTIO_MAX_TXQS? If the driver can't handle all ofthem,
Quoted 1 line
it should simply not use them...
The main reason was vhost :) Since
vhost_net_releaseshould not fail (__fputcan't handlef_op->release()failure), I needed a maximum number of socks to clean up:
Ah, then it belongs in the vhost headers. The guest shouldn't see such a restriction if it doesn't apply; it's a host thing.
Oh, and I think you could profitably use virtio_config_val(), too.
Thanks!
Rusty.
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Rusty Russell <[email protected]> wrote on 09/09/2010 05:44:25 PM:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This seems a bit weird. I mean, the driver used vdev->config->
find_vqs
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
to find the queues, which returns them (in order). So, can't you put
this
Quoted 1 line
into your struct
send_queue?I am saving the vqs in the
send_queue, but the cb needs to locate the device txq from the svq. The only other way I could think of is to iterate through the send_queue's and compare svq against sq[i]->svq, but cb's happen quite a bit. Is there a better way?Ah, good point. Move the queue index into the struct virtqueue?
Is it OK to move the queue_index from virtio_pci_vq_info to virtqueue? I didn't want to change any data structures in virtio for this patch, but I can do it either way.
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Also, why define
VIRTIO_MAX_TXQS? If the driver can't handle all ofthem,
Quoted 1 line
it should simply not use them...
The main reason was vhost :) Since
vhost_net_releaseshould not fail (__fputcan't handlef_op->release()failure), I needed a maximum number of socks to clean up:
Quoted 4 lines
Ah, then it belongs in the vhost headers. The guest shouldn't see such a restriction if it doesn't apply; it's a host thing.
Oh, and I think you could profitably use
virtio_config_val(), too.
OK, I will make those changes. Thanks for the reference to virtio_config_val(), I will use it in guest probe instead of the cumbersome way I am doing now. Unfortunately I need a constant in vhost for now.
Thanks,
- KK
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 6 lines · On Thu, 9 Sep 2010 11:19:33 pm Krishna Kumar2 wrote:
Rusty Russell <[email protected]> wrote on 09/09/2010 05:44:25 PM:
Quoted 1 line
Ah, good point. Move the queue index into the struct virtqueue?
Is it OK to move the
queue_indexfromvirtio_pci_vq_infoto virtqueue? I didn't want to change any data structures in virtio for this patch, but I can do it either way.
Yep, it's logical to me.
Thanks!
Rusty.
Michael S. Tsirkin
maintainerRe: [RFC PATCH 1/4] Add a new API to virtio-pci
In reply to Krishna Kumar2Quoted 2 lines · On Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Unfortunately I need a
constant in vhost for now.
Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of vhost_net.h in qemu.
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
"Michael S. Tsirkin" <[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 11 lines
"Michael S. Tsirkin" <[email protected]>
09/12/2010 05:16 PMQuoted 2 lines · On Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.
Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in vhost_setup_vqs. Then I can remove all "socks" parameters in vhost_net_stop, vhost_net_release and vhost_net_reset_owner.
Does this make sense?
Thanks,
- KK
Michael S. Tsirkin
maintainerRe: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 21 lines · On Mon, Sep 13, 2010 at 09:50:42AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin" <[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 11 lines
"Michael S. Tsirkin" <[email protected]>
09/12/2010 05:16 PMQuoted 2 lines · On Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in
vhost_setup_vqs. Then I can remove all "socks" parameters invhost_net_stop,vhost_net_releaseandvhost_net_reset_owner.
Quoted 5 lines
Does this make sense?
Thanks,
- KK
Here's what I mean: each vhost device includes 1 TX and 1 RX VQ. Instead of teaching vhost about multiqueue, we could simply open /dev/vhost-net multiple times. How many times would be up to qemu.
Signature · 1 line
MST
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · On Mon, Sep 13, 2010 at 09:50:42AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin"<[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 5 lines
"Michael S. Tsirkin"<[email protected]>
09/12/2010 05:16 PMOn Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Quoted 8 lines
Quoted 3 lines
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in
vhost_setup_vqs. Then I can remove all "socks" parameters invhost_net_stop,vhost_net_releaseandvhost_net_reset_owner.Does this make sense?
Quoted 9 lines
Quoted 4 lines
Thanks,
- KK
Here's what I mean: each vhost device includes 1 TX and 1 RX VQ. Instead of teaching vhost about multiqueue, we could simply open
/dev/vhost-netmultiple times. How many times would be up to qemu.
Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Regards,
Anthony Liguori
Michael S. Tsirkin
maintainerRe: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 35 lines · Anthony Liguori
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · On Mon, Sep 13, 2010 at 09:50:42AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin"<[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 10 lines
"Michael S. Tsirkin"<[email protected]>
09/12/2010 05:16 PMQuoted 2 lines · On Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in
vhost_setup_vqs. Then I can remove all "socks" parameters invhost_net_stop,vhost_net_releaseandvhost_net_reset_owner.Does this make sense?
Quoted 7 lines
Quoted 3 lines
Thanks,
- KK
Here's what I mean: each vhost device includes 1 TX and 1 RX VQ. Instead of teaching vhost about multiqueue, we could simply open
/dev/vhost-netmultiple times. How many times would be up to qemu.Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
Quoted 7 lines
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Regards,
Anthony Liguori
Not really, TX and RX can be mapped to different devices, or you can only map one of these. What is the trouble? What other features would you desire in terms of flexibility?
Signature · 1 line
MST
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 8 lines · Michael S. Tsirkin
Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Quoted 5 lines
Regards,
Anthony Liguori
Not really, TX and RX can be mapped to different devices, or you can only map one of these. What is the trouble?
Suppose you have one multiqueue-capable ethernet card. How can you connect it to multiple rx/tx queues?
tx is in principle doable, but what about rx?
What does "only map one of these" mean? Connect the device with one queue (presumably rx), and terminate the others?
Will packet classification work (does the current multiqueue proposal support it)?
Signature · 1 line
error compiling committee.c: too many arguments to function
Michael S. Tsirkin
maintainerRe: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 19 lines · Avi Kivity
Quoted 8 lines · Michael S. Tsirkin
Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Quoted 5 lines
Regards,
Anthony Liguori
Not really, TX and RX can be mapped to different devices, or you can only map one of these. What is the trouble?Suppose you have one multiqueue-capable ethernet card. How can you connect it to multiple rx/tx queues?
tx is in principle doable, but what about rx?
Quoted 7 lines
What does "only map one of these" mean? Connect the device with one queue (presumably rx), and terminate the others?
Will packet classification work (does the current multiqueue proposal support it)?
This is a non trivial problem, but
this needs to be handled in tap, not in vhost net. If tap gives you multiple queues, vhost-net will happily let you connect vqs to these.
Quoted 8 lines
Signature · 7 lines
-- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/4] Add a new API to virtio-pci
In reply to Michael S. TsirkinQuoted 48 lines · Michael S. Tsirkin
Quoted 46 lines · Anthony Liguori
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · On Mon, Sep 13, 2010 at 09:50:42AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin"<[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 5 lines
"Michael S. Tsirkin"<[email protected]>
09/12/2010 05:16 PMOn Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Quoted 8 lines
Quoted 3 lines
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in
vhost_setup_vqs. Then I can remove all "socks" parameters invhost_net_stop,vhost_net_releaseandvhost_net_reset_owner.Does this make sense?
Quoted 9 lines
Quoted 4 lines
Thanks,
- KK
Here's what I mean: each vhost device includes 1 TX and 1 RX VQ. Instead of teaching vhost about multiqueue, we could simply open
/dev/vhost-netmultiple times. How many times would be up to qemu.Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Quoted 6 lines
Quoted 4 lines
Regards,
Anthony Liguori
Not really, TX and RX can be mapped to different devices,
It's just a little odd. Would you bond multiple tun tap devices to achieve multi-queue TX? For RX, do you somehow limit RX to only one of those devices?
If we were doing this in QEMU (and btw, there needs to be userspace patches before we implement this in the kernel side), I think it would make more sense to just rely on doing a multithreaded write to a single tun/tap device and then to hope that in can be made smarter at the macvtap layer.
Regards,
Anthony Liguori
Regards,
Anthony Liguori
Quoted 4 lines
or you can only map one of these. What is the trouble? What other features would you desire in terms of flexibility?
Michael S. Tsirkin
maintainerRe: [RFC PATCH 1/4] Add a new API to virtio-pci
Quoted 40 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Anthony Liguori
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · On Mon, Sep 13, 2010 at 09:50:42AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin"<[email protected]> wrote on 09/12/2010 05:16:37 PM:
Quoted 10 lines
"Michael S. Tsirkin"<[email protected]>
09/12/2010 05:16 PMQuoted 2 lines · On Thu, Sep 09, 2010 at 07:19:33PM +0530, Krishna Kumar2 wrote:
Unfortunately I need a
constant in vhost for now.Maybe not even that: you create multiple vhost-net devices so vhost-net in kernel does not care about these either, right? So this can be just part of
vhost_net.hin qemu.Sorry, I didn't understand what you meant.
I can remove all socks[] arrays/constants by pre-allocating sockets in
vhost_setup_vqs. Then I can remove all "socks" parameters invhost_net_stop,vhost_net_releaseandvhost_net_reset_owner.Does this make sense?
Quoted 7 lines
Quoted 3 lines
Thanks,
- KK
Here's what I mean: each vhost device includes 1 TX and 1 RX VQ. Instead of teaching vhost about multiqueue, we could simply open
/dev/vhost-netmultiple times. How many times would be up to qemu.Trouble is, each vhost-net device is associated with 1 tun/tap device which means that each vhost-net device is associated with a transmit and receive queue.
I don't know if you'll always have an equal number of transmit and receive queues but there's certainly challenge in terms of flexibility with this model.
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Regards,
Anthony Liguori
Not really, TX and RX can be mapped to different devices,
It's just a little odd. Would you bond multiple tun tap devices to achieve multi-queue TX? For RX, do you somehow limit RX to only one of those devices?
Exatly in the way the patches we discuss here do this:
we already have a per-queue fd.
Quoted 2 lines
If we were doing this in QEMU (and btw, there needs to be userspace patches before we implement this in the kernel side),
I agree that Feature parity is nice to have, but
I don't see a huge problem with (hopefully temporarily) only supporting feature X with kernel acceleration, BTW. This is already the case with checksum offloading features.
Quoted 4 lines
I think it
would make more sense to just rely on doing a multithreaded write to a single tun/tap device and then to hope that in can be made smarter at the macvtap layer.
No, an fd serializes access, so you need seperate fds for multithreaded writes to work. Think about how e.g. select will work.
Quoted 16 lines
Regards,
Anthony Liguori
Regards,
Anthony Liguori
Quoted 3 lines
or you can only map one of these. What is the trouble? What other features would you desire in terms of flexibility?
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 2/4 Changes for virtio-net
In reply to Krishna KumarImplement mq virtio-net driver.
Though struct virtio_net_config changes, it works with old qemu's since the last element is not accessed, unless qemu sets VIRTIO_NET_F_NUMTXQS.
--- drivers/net/virtio_net.c | 213 ++++++++++++++++++++++++++--------- include/linux/virtio_net.h | 6 2 files changed, 166 insertions(+), 53 deletions(-)
include/linux/virtio_net.h +6 -0
@@ -7,6 +7,9 @@#include <linux/virtio_config.h> #include <linux/if_ether.h> +/* The maximum of transmit queues supported */ +#define VIRTIO_MAX_TXQS 16 +/* The feature bitmap for virtio net */ #define VIRTIO_NET_F_CSUM 0/* Host handles pkts w/ partial csum */ #define VIRTIO_NET_F_GUEST_CSUM 1/* Guest handles pkts w/ partial csum */
@@ -26,6 +29,7 @@#define VIRTIO_NET_F_CTRL_RX 18/* Control channel RX mode support */ #define VIRTIO_NET_F_CTRL_VLAN 19/* Control channel VLAN filtering */ #define VIRTIO_NET_F_CTRL_RX_EXTRA 20/* Extra RX mode control support */ +#define VIRTIO_NET_F_NUMTXQS 21/* Device supports multiple TX queue */ #define VIRTIO_NET_S_LINK_UP 1/* Link is up */
@@ -34,6 +38,8 @@ struct virtio_net_config {__u8 mac[6 ];/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ __u16 status; +/* number of transmit queues */ +__u16 numtxqs; } __attribute__((packed));/* This is the first element of the scatter-gather list. If you don't
drivers/net/virtio_net.c +160 -53
356 lines not on this page · raw message
RFC PATCH 3/4 Changes for vhost
In reply to Krishna KumarChanges for mq vhost.
vhost_net_open is changed to allocate a vhost_net and return. The remaining initializations are delayed till SET_OWNER. SET_OWNER is changed so that the argument is used to figure out how many txqs to use. Unmodified qemu's will pass NULL, so this is recognized and handled as numtxqs=1.
Besides changing handle_tx to use 'vq', this patch also changes handle_rx to take vq as parameter. The mq RX patch requires this change, but till then it is consistent (and less confusing) to make the interfaces for handling rx and tx similar.
--- drivers/vhost/net.c | 272 ++++++++++++++++++++++++++-------------- drivers/vhost/vhost.c | 152 ++++++++++++++-------- drivers/vhost/vhost.h | 15 +- 3 files changed, 289 insertions(+), 150 deletions(-)
drivers/vhost/net.c +181 -91
@@ -33,12 +33,6 @@* Using this limit prevents one virtqueue from starving others. */ #define VHOST_NET_WEIGHT 0x80000 -enum { -VHOST_NET_VQ_RX =0 , -VHOST_NET_VQ_TX =1 , -VHOST_NET_VQ_MAX =2 , -}; -enum vhost_net_poll_state {VHOST_NET_POLL_DISABLED =0 ,VHOST_NET_POLL_STARTED =1 ,
@@ -47,12 +41,12 @@ enum vhost_net_poll_state {struct vhost_net {struct vhost_dev dev; -struct vhost_virtqueue vqs[VHOST_NET_VQ_MAX ]; -struct vhost_poll poll[VHOST_NET_VQ_MAX ]; +struct vhost_virtqueue *vqs; +struct vhost_poll *poll;/* Tells us whether we are polling a socket for TX. * We only do this when socket buffer fills up. * Protected by tx vq lock. */ -enum vhost_net_poll_state tx_poll_state; +enum vhost_net_poll_state *tx_poll_state; };/* Pop first len bytes from iovec. Return number of segments used. */
@@ -92,28 +86,28 @@ static void copy_iovec_hdr(const struct }/* Caller must have TX VQ lock */ -static void tx_poll_stop (struct vhost_net *net) +static void tx_poll_stop (struct vhost_net *net,int qnum) { -if (likely (net->tx_poll_state !=VHOST_NET_POLL_STARTED )) +if (likely (net->tx_poll_state[qnum] !=VHOST_NET_POLL_STARTED ))return ; -vhost_poll_stop (net->poll +VHOST_NET_VQ_TX ); - net->tx_poll_state =VHOST_NET_POLL_STOPPED ; +vhost_poll_stop (&net->poll[qnum]); + net->tx_poll_state[qnum] =VHOST_NET_POLL_STOPPED ; }/* Caller must have TX VQ lock */ -static void tx_poll_start (struct vhost_net *net,struct socket *sock) +static void tx_poll_start (struct vhost_net *net,struct socket *sock,int qnum) { -if (unlikely (net->tx_poll_state !=VHOST_NET_POLL_STOPPED )) +if (unlikely (net->tx_poll_state[qnum] !=VHOST_NET_POLL_STOPPED ))return ; -vhost_poll_start (net->poll +VHOST_NET_VQ_TX , sock->file); - net->tx_poll_state =VHOST_NET_POLL_STARTED ; +vhost_poll_start (&net->poll[qnum], sock->file); + net->tx_poll_state[qnum] =VHOST_NET_POLL_STARTED ; }/* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */ -static void handle_tx (struct vhost_net *net) +static void handle_tx (struct vhost_virtqueue *vq) { -struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_TX ]; + struct vhost_net *net = container_of(vq->dev, struct vhost_net, dev);unsigned out, in, s;int head;struct msghdr msg = {
@@ -134,7 +128,7 @@ static void handle_tx(struct vhost_net * wmem =atomic_read (&sock->sk->sk_wmem_alloc);if (wmem >= sock->sk->sk_sndbuf) {mutex_lock (&vq->mutex); -tx_poll_start (net, sock); +tx_poll_start (net, sock, vq->qnum);mutex_unlock (&vq->mutex);return ; }
@@ -144,7 +138,7 @@ static void handle_tx(struct vhost_net *vhost_disable_notify (vq);if (wmem < sock->sk->sk_sndbuf /2 ) -tx_poll_stop (net); +tx_poll_stop (net, vq->qnum); hdr_size = vq->vhost_hlen;for (;;) {
@@ -159,7 +153,7 @@ static void handle_tx(struct vhost_net *if (head == vq->num) { wmem =atomic_read (&sock->sk->sk_wmem_alloc);if (wmem >= sock->sk->sk_sndbuf *3 /4 ) { -tx_poll_start (net, sock); +tx_poll_start (net, sock, vq->qnum);set_bit (SOCK_ASYNC_NOSPACE , &sock->flags);break ; }
@@ -189,7 +183,7 @@ static void handle_tx(struct vhost_net * err = sock->ops->sendmsg (NULL , sock, &msg, len);if (unlikely (err <0 )) {vhost_discard_vq_desc (vq,1 ); -tx_poll_start (net, sock); +tx_poll_start (net, sock, vq->qnum);break ; }if (err != len)
@@ -282,9 +276,9 @@ err:/* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */ -static void handle_rx_big (struct vhost_net *net) +static void handle_rx_big (struct vhost_virtqueue *vq, +struct vhost_net *net) { -struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX ];unsigned out, in, log, s;int head;struct vhost_log *vq_log;
@@ -393,9 +387,9 @@ static void handle_rx_big(struct vhost_n/* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */ -static void handle_rx_mergeable (struct vhost_net *net) +static void handle_rx_mergeable (struct vhost_virtqueue *vq, +struct vhost_net *net) { -struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX ];unsigned uninitialized_var (in ), log;struct vhost_log *vq_log;struct msghdr msg = {
@@ -500,96 +494,179 @@ static void handle_rx_mergeable(struct vunuse_mm (net->dev.mm); } -static void handle_rx (struct vhost_net *net) +static void handle_rx (struct vhost_virtqueue *vq) { + struct vhost_net *net = container_of(vq->dev, struct vhost_net, dev); +if (vhost_has_feature (&net->dev,VIRTIO_NET_F_MRG_RXBUF )) -handle_rx_mergeable (net); +handle_rx_mergeable (vq, net);else -handle_rx_big (net); +handle_rx_big (vq, net); }static void handle_tx_kick (struct vhost_work *work) { struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, poll.work); - struct vhost_net *net = container_of(vq->dev, struct vhost_net, dev); -handle_tx (net); +handle_tx (vq); }static void handle_rx_kick (struct vhost_work *work) { struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, poll.work); - struct vhost_net *net = container_of(vq->dev, struct vhost_net, dev); -handle_rx (net); +handle_rx (vq); }static void handle_tx_net (struct vhost_work *work) { - struct vhost_net *net = container_of(work, struct vhost_net, - poll[VHOST_NET_VQ_TX ].work); -handle_tx (net); + struct vhost_virtqueue *vq = container_of(work, struct vhost_poll, + work)->vq; + +handle_tx (vq); }static void handle_rx_net (struct vhost_work *work) { - struct vhost_net *net = container_of(work, struct vhost_net, - poll[VHOST_NET_VQ_RX ].work); -handle_rx (net); + struct vhost_virtqueue *vq = container_of(work, struct vhost_poll, + work)->vq; + +handle_rx (vq); } -static int vhost_net_open (struct inode *inode,struct file *f) +void vhost_free_vqs (struct vhost_dev *dev) { -struct vhost_net *n =kmalloc (sizeof *n,GFP_KERNEL ); -struct vhost_dev *dev; -int r; + struct vhost_net *n = container_of(dev, struct vhost_net, dev); -if (!n) -return -ENOMEM ; +kfree (dev->work_list); +kfree (dev->work_lock); +kfree (n->tx_poll_state); +kfree (n->poll); +kfree (n->vqs); - dev = &n->dev; - n->vqs[VHOST_NET_VQ_TX ].handle_kick = handle_tx_kick; - n->vqs[VHOST_NET_VQ_RX ].handle_kick = handle_rx_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_NET_VQ_MAX ); -if (r <0 ) { -kfree (n); -return r; +/* +* Reset so that vhost_net_release (after vhost_dev_set_owner call) +* will notice. +*/ + n->vqs =NULL ; + n->poll =NULL ; + n->tx_poll_state =NULL ; + dev->work_lock =NULL ; + dev->work_list =NULL ; +} + +/* Upper limit of how many vq's we support - 1 RX and VIRTIO_MAX_TXQS TX vq's */ +#define MAX_VQS (1 + VIRTIO_MAX_TXQS) + +int vhost_setup_vqs (struct vhost_dev *dev,int numtxqs) +{ + struct vhost_net *n = container_of(dev, struct vhost_net, dev); +int i, nvqs; +int ret; + +if (numtxqs <0 || numtxqs >VIRTIO_MAX_TXQS ) +return -EINVAL ; + +if (numtxqs ==0 ) { +/* Old qemu doesn't pass arguments to set_owner, use 1 txq */ + numtxqs =1 ; } -vhost_poll_init (n->poll +VHOST_NET_VQ_TX , handle_tx_net,POLLOUT , dev); -vhost_poll_init (n->poll +VHOST_NET_VQ_RX , handle_rx_net,POLLIN , dev); - n->tx_poll_state =VHOST_NET_POLL_DISABLED ; +/* Total number of virtqueues is numtxqs + 1 */ + nvqs = numtxqs +1 ; + + n->vqs =kmalloc (nvqs *sizeof (*n->vqs),GFP_KERNEL ); + n->poll =kmalloc (nvqs *sizeof (*n->poll),GFP_KERNEL ); + +/* Allocate 1 more tx_poll_state than required for convenience */ + n->tx_poll_state =kmalloc (nvqs *sizeof (*n->tx_poll_state), +GFP_KERNEL ); + dev->work_lock =kmalloc (nvqs *sizeof (*dev->work_lock), +GFP_KERNEL ); + dev->work_list =kmalloc (nvqs *sizeof (*dev->work_list), +GFP_KERNEL ); + +if (!n->vqs || !n->poll || !n->tx_poll_state || !dev->work_lock || + !dev->work_list) { + ret = -ENOMEM ; + goto err; + } - f->private_data = n; +/* 1 RX, followed by 'numtxqs' TX queues */ + n->vqs[0 ].handle_kick = handle_rx_kick; + +for (i =1 ; i < nvqs; i++) + n->vqs[i].handle_kick = handle_tx_kick; + + ret =vhost_dev_init (dev, n->vqs, nvqs); +if (ret <0 ) + goto err; + +vhost_poll_init (&n->poll[0 ], handle_rx_net,POLLIN , &n->vqs[0 ]); + +for (i =1 ; i < nvqs; i++) { +vhost_poll_init (&n->poll[i], handle_tx_net,POLLOUT , + &n->vqs[i]); + n->tx_poll_state[i] =VHOST_NET_POLL_DISABLED ; + }return 0 ; + +err: +/* Free all pointers that may have been allocated */ +vhost_free_vqs (dev); + +return ret; +} + +static int vhost_net_open (struct inode *inode,struct file *f) +{ +struct vhost_net *n =kzalloc (sizeof *n,GFP_KERNEL ); +int ret =ENOMEM ; + +if (n) { +struct vhost_dev *dev = &n->dev; + + f->private_data = n; +mutex_init (&dev->mutex); + +/* Defer all other initialization till user does SET_OWNER */ + ret =0 ; + } + +return ret; }static void vhost_net_disable_vq (struct vhost_net *n,struct vhost_virtqueue *vq) { +int qnum = vq->qnum; +if (!vq->private_data)return ; -if (vq == n->vqs +VHOST_NET_VQ_TX ) { -tx_poll_stop (n); - n->tx_poll_state =VHOST_NET_POLL_DISABLED ; +if (qnum) {/* TX */ +tx_poll_stop (n, qnum); + n->tx_poll_state[qnum] =VHOST_NET_POLL_DISABLED ; }else -vhost_poll_stop (n->poll +VHOST_NET_VQ_RX ); +vhost_poll_stop (&n->poll[qnum]); }static void vhost_net_enable_vq (struct vhost_net *n,struct vhost_virtqueue *vq) {struct socket *sock = vq->private_data; +int qnum = vq->qnum; +if (!sock)return ; -if (vq == n->vqs +VHOST_NET_VQ_TX ) { - n->tx_poll_state =VHOST_NET_POLL_STOPPED ; -tx_poll_start (n, sock); + +if (qnum) {/* TX */ + n->tx_poll_state[qnum] =VHOST_NET_POLL_STOPPED ; +tx_poll_start (n, sock, qnum); }else -vhost_poll_start (n->poll +VHOST_NET_VQ_RX , sock->file); +vhost_poll_start (&n->poll[qnum], sock->file); } static struct socket *vhost_net_stop_vq(struct vhost_net *n,
@@ -605,11 +682,12 @@ static struct socket *vhost_net_stop_vq(return sock; } -static void vhost_net_stop (struct vhost_net *n,struct socket **tx_sock, -struct socket **rx_sock) +static void vhost_net_stop (struct vhost_net *n,struct socket **socks) { - *tx_sock =vhost_net_stop_vq (n, n->vqs +VHOST_NET_VQ_TX ); - *rx_sock =vhost_net_stop_vq (n, n->vqs +VHOST_NET_VQ_RX ); +int i; + +for (i = n->dev.nvqs -1 ; i >=0 ; i--) + socks[i] =vhost_net_stop_vq (n, &n->vqs[i]); }static void vhost_net_flush_vq (struct vhost_net *n,int index)
@@ -620,26 +698,34 @@ static void vhost_net_flush_vq(struct vhstatic void vhost_net_flush (struct vhost_net *n) { -vhost_net_flush_vq (n,VHOST_NET_VQ_TX ); -vhost_net_flush_vq (n,VHOST_NET_VQ_RX ); +int i; + +for (i = n->dev.nvqs -1 ; i >=0 ; i--) +vhost_net_flush_vq (n, i); }static int vhost_net_release (struct inode *inode,struct file *f) {struct vhost_net *n = f->private_data; -struct socket *tx_sock; -struct socket *rx_sock; +struct vhost_dev *dev = &n->dev; +struct socket *socks[MAX_VQS ]; +int i; -vhost_net_stop (n, &tx_sock, &rx_sock); +vhost_net_stop (n, socks);vhost_net_flush (n); -vhost_dev_cleanup (&n->dev); -if (tx_sock) -fput (tx_sock->file); -if (rx_sock) -fput (rx_sock->file); +vhost_dev_cleanup (dev); + +for (i = n->dev.nvqs -1 ; i >=0 ; i--) +if (socks[i]) +fput (socks[i]->file); +/* We do an extra flush before freeing memory, * since jobs can re-queue themselves. */ vhost_net_flush (n); + +/* Free all old pointers */ +vhost_free_vqs (dev); +kfree (n);return 0 ; }
@@ -717,7 +803,7 @@ static long vhost_net_set_backend(structif (r) goto err; -if (index >=VHOST_NET_VQ_MAX ) { +if (index >= n->dev.nvqs) { r = -ENOBUFS ; goto err; }
@@ -762,22 +848,26 @@ err:static long vhost_net_reset_owner (struct vhost_net *n) { -struct socket *tx_sock =NULL ; -struct socket *rx_sock =NULL ; +struct socket *socks[MAX_VQS ];long err; +int i; +mutex_lock (&n->dev.mutex); err =vhost_dev_check_owner (&n->dev); -if (err) - goto done; -vhost_net_stop (n, &tx_sock, &rx_sock); +if (err) { +mutex_unlock (&n->dev.mutex); +return err; + } + +vhost_net_stop (n, socks);vhost_net_flush (n); err =vhost_dev_reset_owner (&n->dev); -done:mutex_unlock (&n->dev.mutex); -if (tx_sock) -fput (tx_sock->file); -if (rx_sock) -fput (rx_sock->file); + +for (i = n->dev.nvqs -1 ; i >=0 ; i--) +if (socks[i]) +fput (socks[i]->file); +return err; }
@@ -806,7 +896,7 @@ static int vhost_net_set_features(struct } n->dev.acked_features = features;smp_wmb (); -for (i =0 ; i <VHOST_NET_VQ_MAX ; ++i) { +for (i =0 ; i < n->dev.nvqs; ++i) {mutex_lock (&n->vqs[i].mutex); n->vqs[i].vhost_hlen = vhost_hlen; n->vqs[i].sock_hlen = sock_hlen;
drivers/vhost/vhost.c +98 -54
249 lines not on this page · raw message
drivers/vhost/vhost.h +10 -5
@@ -40,11 +40,11 @@ struct vhost_poll {wait_queue_t wait;struct vhost_work work;unsigned long mask; -struct vhost_dev *dev; +struct vhost_virtqueue *vq;/* points back to vq */ };void vhost_poll_init (struct vhost_poll *poll,vhost_work_fn_t fn, -unsigned long mask,struct vhost_dev *dev); +unsigned long mask,struct vhost_virtqueue *vq);void vhost_poll_start (struct vhost_poll *poll,struct file *file);void vhost_poll_stop (struct vhost_poll *poll);void vhost_poll_flush (struct vhost_poll *poll);
@@ -110,6 +110,10 @@ struct vhost_virtqueue {/* Log write descriptors */ void __user *log_base;struct vhost_log log[VHOST_NET_MAX_SG ]; +struct task_struct *worker;/* vhost for this vq, shared btwn RX/TX */ +spinlock_t *work_lock; +struct list_head *work_list; +int qnum;/* 0 for RX, 1 -> n-1 for TX */ };struct vhost_dev {
@@ -124,11 +128,12 @@ struct vhost_dev {int nvqs;struct file *log_file;struct eventfd_ctx *log_ctx; -spinlock_t work_lock; -struct list_head work_list; -struct task_struct *worker; +spinlock_t *work_lock; +struct list_head *work_list; }; +int vhost_setup_vqs (struct vhost_dev *dev,int numtxqs); +void vhost_free_vqs (struct vhost_dev *dev);long vhost_dev_init (struct vhost_dev *,struct vhost_virtqueue *vqs,int nvqs);long vhost_dev_check_owner (struct vhost_dev *);long vhost_dev_reset_owner (struct vhost_dev *);
RFC PATCH 4/4 qemu changes
In reply to Krishna KumarChanges in qemu to support mq TX.
--- hw/vhost.c | 8 ++- hw/vhost.h | 2 hw/vhost_net.c | 16 +++++-- hw/vhost_net.h | 2 hw/virtio-net.c | 97 ++++++++++++++++++++++++++++++---------------- hw/virtio-net.h | 5 ++ hw/virtio-pci.c | 2 net.c | 17 ++++++++ net.h | 1 net/tap.c | 61 +++++++++++++++++++++------- 10 files changed, 155 insertions(+), 56 deletions(-)
hw/vhost.c +6 -2
@@ -599,23 +599,27 @@ static void vhost_virtqueue_cleanup(stru 0, virtio_queue_get_desc_size(vdev, idx)); } -int vhost_dev_init (struct vhost_dev *hdev,int devfd) +int vhost_dev_init (struct vhost_dev *hdev,int devfd,int numtxqs) {uint64_t features;int r;if (devfd >=0 ) { hdev->control = devfd; + hdev->nvqs =2 ; }else { hdev->control =open ("/dev/vhost-net" ,O_RDWR );if (hdev->control <0 ) {return -errno; } } - r =ioctl (hdev->control,VHOST_SET_OWNER ,NULL ); + + r =ioctl (hdev->control,VHOST_SET_OWNER , numtxqs);if (r <0 ) { goto fail; } + hdev->nvqs = numtxqs +1 ; + r =ioctl (hdev->control,VHOST_GET_FEATURES , &features);if (r <0 ) { goto fail;
hw/vhost.h +1 -1
@@ -40,7 +40,7 @@ struct vhost_dev {unsigned long long log_size; }; -int vhost_dev_init (struct vhost_dev *hdev,int devfd); +int vhost_dev_init (struct vhost_dev *hdev,int devfd,int nvqs);void vhost_dev_cleanup (struct vhost_dev *hdev);int vhost_dev_start (struct vhost_dev *hdev,VirtIODevice *vdev);void vhost_dev_stop (struct vhost_dev *hdev,VirtIODevice *vdev);
hw/vhost_net.c +11 -5
@@ -36,7 +36,8 @@struct vhost_net {struct vhost_dev dev; -struct vhost_virtqueue vqs[2 ]; +struct vhost_virtqueue *vqs; +int nvqs;int backend;VLANClientState *vc; };
@@ -76,7 +77,8 @@ static int vhost_net_get_fd(VLANClientSt } } -struct vhost_net *vhost_net_init (VLANClientState *backend,int devfd) +struct vhost_net *vhost_net_init (VLANClientState *backend,int devfd, +int numtxqs) {int r;struct vhost_net *net =qemu_malloc (sizeof *net);
@@ -93,10 +95,14 @@ struct vhost_net *vhost_net_init(VLANCli (1 <<VHOST_NET_F_VIRTIO_NET_HDR ); net->backend = r; - r =vhost_dev_init (&net->dev, devfd); + r =vhost_dev_init (&net->dev, devfd, numtxqs);if (r <0 ) { goto fail; } + + net->nvqs = numtxqs +1 ; + net->vqs =qemu_malloc (net->nvqs * (sizeof *net->vqs)); +if (~net->dev.features & net->dev.backend_features) {fprintf (stderr,"vhost lacks feature mask %" PRIu64" for backend\n" , (uint64_t )(~net->dev.features & net->dev.backend_features));
@@ -118,7 +124,6 @@ int vhost_net_start(struct vhost_net *nestruct vhost_vring_file file = { };int r; - net->dev.nvqs =2 ; net->dev.vqs = net->vqs; r =vhost_dev_start (&net->dev, dev);if (r <0 ) {
@@ -166,7 +171,8 @@ void vhost_net_cleanup(struct vhost_net qemu_free(net); }#else -struct vhost_net *vhost_net_init (VLANClientState *backend,int devfd) +struct vhost_net *vhost_net_init (VLANClientState *backend,int devfd, +int nvqs) {return NULL ; }
hw/vhost_net.h +1 -1
@@ -6,7 +6,7 @@struct vhost_net ;typedef struct vhost_net VHostNetState ; -VHostNetState *vhost_net_init (VLANClientState *backend,int devfd); +VHostNetState *vhost_net_init (VLANClientState *backend,int devfd,int nvqs);int vhost_net_start (VHostNetState *net,VirtIODevice *dev);void vhost_net_stop (VHostNetState *net,VirtIODevice *dev);
hw/virtio-net.c +65 -32
228 lines not on this page · raw message
hw/virtio-net.h +5 -0
@@ -22,6 +22,9 @@/* from Linux's virtio_net.h */ +/* The maximum of transmit (& separate receive) queues supported */ +#define VIRTIO_MAX_TXQS 16 +/* The ID for virtio_net */ #define VIRTIO_ID_NET 1
@@ -44,6 +47,7 @@#define VIRTIO_NET_F_CTRL_RX 18/* Control channel RX mode support */ #define VIRTIO_NET_F_CTRL_VLAN 19/* Control channel VLAN filtering */ #define VIRTIO_NET_F_CTRL_RX_EXTRA 20/* Extra RX mode control support */ +#define VIRTIO_NET_F_NUMTXQS 21/* Supports multiple TX queues */ #define VIRTIO_NET_S_LINK_UP 1/* Link is up */
@@ -58,6 +62,7 @@ struct virtio_net_configuint8_t mac[ETH_ALEN ];/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ uint16_t status; +uint16_t numtxqs;/* number of transmit queues */ } __attribute__((packed));/* This is the first element of the scatter-gather list. If you don't
hw/virtio-pci.c +2 -0
@@ -99,6 +99,7 @@ typedef struct {uint32_t addr;uint32_t class_code;uint32_t nvectors; +uint32_t mq;BlockConf block;NICConf nic;uint32_t host_features;
@@ -722,6 +723,7 @@ static PCIDeviceInfo virtio_info[] = { .romfile = "pxe-virtio.bin", .qdev.props = (Property []) {DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors,3 ), +DEFINE_PROP_UINT32 ("mq" , VirtIOPCIProxy, mq,1 ),DEFINE_VIRTIO_NET_FEATURES (VirtIOPCIProxy, host_features),DEFINE_NIC_PROPERTIES (VirtIOPCIProxy, nic),DEFINE_PROP_END_OF_LIST (),
net/tap.c +46 -15
137 lines not on this page · raw message
net.c +17 -0
@@ -814,6 +814,15 @@ static int net_init_nic(QemuOpts *opts,return -1 ; } +if (nd->netdev->numtxqs >1 && nd->nvectors ==DEV_NVECTORS_UNSPECIFIED ) { +/* +* User specified mq for guest, but no "vectors=", tune +* it automatically to 'numtxqs' TX + 1 RX + 1 controlq. +*/ + nd->nvectors = nd->netdev->numtxqs +1 +1 ; +monitor_printf (mon,"nvectors tuned to %d\n" , nd->nvectors); + } + nd->used =1 ; nb_nics++;
@@ -957,6 +966,14 @@ static const struct { }, #ifndef _WIN32 { + .name = "mq", + .type = QEMU_OPT_BOOL, + .help = "enable multiqueue on network i/f", + }, { + .name = "numtxqs", + .type = QEMU_OPT_NUMBER, + .help = "optional number of TX queues, if mq is enabled", + }, { .name = "fd", .type = QEMU_OPT_STRING, .help = "file descriptor of an already opened tap",
net.h +1 -0
@@ -62,6 +62,7 @@ struct VLANClientState {struct VLANState *vlan;VLANClientState *peer;NetQueue *send_queue; +int numtxqs;char *model;char *name;char info_str[256 ];
Quoted 8 lines · Krishna Kumar
Following patches implement Transmit mq in virtio-net. Also included is the user qemu changes.
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
Why were vhost kernel changes required? Can't you just instantiate more vhost queues?
Quoted 8 lines
2. For this mq TX patch, 1 daemon is created for RX and 'n' daemons for the 'n' TXQ's, for a total of (n+1) daemons. The (subsequent) RX mq patch changes that to a total of 'n' daemons, where RX and TX vq's share 1 daemon.
3. Service Demand increases for TCP, but significantly improves for UDP.
4. Interoperability: Many combinations, but not all, of qemu, host, guest tested together.
Please update the virtio-pci spec @ http://ozlabs.org/~rusty/virtio-spec/.
Quoted 36 lines
Enabling mq on virtio:
-----------------------When following options are passed to qemu:
- smp> 1
- vhost=on
- mq=on (new option, default:off)
then #txqueues = #cpus. The #txqueues can be changed by usingan optional 'numtxqs' option. e.g. for a smp=4 guest: vhost=on,mq=on -> #txqueues = 4 vhost=on,mq=on,numtxqs=8 -> #txqueues = 8 vhost=on,mq=on,numtxqs=2 -> #txqueues = 2Performance (guest -> local host): -----------------------------------System configuration:
Host: 8 Intel Xeon, 8 GB memory
Guest: 4 cpus, 2 GB memory
All testing without any tuning, and TCP netperf with 64K I/O
_______________________________________________________________________________TCP (#numtxqs=2) N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%) _______________________________________________________________________________ 4 26387 40716 (54.30) 20 28 (40.00) 86i 85 (-1.16) 8 24356 41843 (71.79) 88 129 (46.59) 372 362 (-2.68) 16 23587 40546 (71.89) 375 564 (50.40) 1558 1519 (-2.50) 32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722 (-14.52) 48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552 (-14.35) 64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173 (-9.66) 96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031 (10.74) _______________________________________________________________________________ UDP (#numtxqs=8)N# BW1 BW2 (%) SD1 SD2 (%)
Quoted 8 lines
__________________________________________________________
4 29836 56761 (90.24) 67 63 (-5.97) 8 27666 63767 (130.48) 326 265 (-18.71) 16 25452 60665 (138.35) 1396 1269 (-9.09) 32 26172 63491 (142.59) 5617 4202 (-25.19) 48 26146 64629 (147.18) 12813 9316 (-27.29) 64 25575 65448 (155.90) 23063 16346 (-29.12) 128 26454 63772 (141.06) 91054 85051 (-6.59)
Impressive results.
Quoted 23 lines
__________________________________________________________
N#: Number of netperf sessions, 90 sec runs BW1,SD1,RSD1: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for original code
BW2,SD2,RSD2: Bandwidth (sum across 2 runs in mbps), SD and RemoteSD for new code. e.g. BW2=40716 means average BW2 was 20358 mbps. Next steps: -----------1. mq RX patch is also complete - plan to submit once TX is OK.
2. Cache-align data structures: I didn't see any BW/SD improvementafter making the sq's (and similarly for vhost) cache-aligned statically: struct virtnet_info { ... struct send_queue sq[16] ____cacheline_aligned_in_smp; ... };Guest interrupts for a 4 TXQ device after a 5 min test:
Quoted 8 lines
# egrep "virtio0|CPU" /proc/interrupts
CPU0 CPU1 CPU2 CPU3
40: 0 0 0 0 PCI-MSI-edge virtio0-config
41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input
42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0
43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1
44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2
45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3How are vhost threads and host interrupts distributed? We need to move vhost queue threads to be colocated with the related vcpu threads (if no extra cores are available) or on the same socket (if extra cores are available). Similarly, move device interrupts to the same core as the vhost thread.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Avi Kivity <[email protected]> wrote on 09/08/2010 01:17:34 PM:
Quoted 12 lines · Krishna Kumar
Quoted 8 lines
Following patches implement Transmit mq in virtio-net. Also included is the user qemu changes.
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
Why were vhost kernel changes required? Can't you just instantiate more vhost queues?
I did try using a single thread processing packets from multiple vq's on host, but the BW dropped beyond a certain number of sessions. I don't have the code and performance numbers for that right now since it is a bit ancient, I can try to resuscitate that if you want.
Quoted 10 lines
Quoted 9 lines
Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts CPU0 CPU1 CPU2 CPU3 40: 0 0 0 0 PCI-MSI-edge virtio0-config 41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input 42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0 43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1 44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2 45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3
Quoted 5 lines
How are vhost threads and host interrupts distributed? We need to move vhost queue threads to be colocated with the related vcpu threads (if no extra cores are available) or on the same socket (if extra cores are available). Similarly, move device interrupts to the same core as the vhost thread.
All my testing was without any tuning, including binding netperf & netserver (irqbalance is also off). I assume (maybe wrongly) that the above might give better results? Are you suggesting this combination:
IRQ on guest:
40: CPU0
41: CPU1
42: CPU2
43: CPU3 (all CPUs are on socket #0)
vhost:
thread #0: CPU0
thread #1: CPU1
thread #2: CPU2
thread #3: CPU3
qemu:
thread #0: CPU4
thread #1: CPU5
thread #2: CPU6
thread #3: CPU7 (all CPUs are on socket#1)
netperf/netserver:
Run on CPUs 0-4 on both sides
The reason I did not optimize anything from user space is because I felt showing the default works reasonably well is important.
Thanks,
- KK
Quoted 11 lines · On 09/08/2010 12:22 PM, Krishna Kumar2 wrote:
Avi Kivity<[email protected]> wrote on 09/08/2010 01:17:34 PM:
Quoted 9 lines · Krishna Kumar
Quoted 8 lines
Following patches implement Transmit mq in virtio-net. Also included is the user qemu changes.
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
Quoted 5 lines
Quoted 2 lines
Why were vhost kernel changes required? Can't you just instantiate more vhost queues?
I did try using a single thread processing packets from multiple vq's on host, but the BW dropped beyond a certain number of sessions.
Oh - so the interface has not changed (which can be seen from the patch). That was my concern, I remembered that we planned for vhost-net to be multiqueue-ready.
The new guest and qemu code work with old vhost-net, just with reduced performance, yes?
Quoted 3 lines
I don't have the code and performance numbers for that right now since it is a bit ancient, I can try to resuscitate that if you want.
No need.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts CPU0 CPU1 CPU2 CPU3 40: 0 0 0 0 PCI-MSI-edge virtio0-config 41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input 42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0 43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1 44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2 45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3
Quoted 8 lines
Quoted 5 lines
How are vhost threads and host interrupts distributed? We need to move vhost queue threads to be colocated with the related vcpu threads (if no extra cores are available) or on the same socket (if extra cores are available). Similarly, move device interrupts to the same core as the vhost thread.
All my testing was without any tuning, including binding netperf& netserver (irqbalance is also off). I assume (maybe wrongly) that the above might give better results?
I hope so!
Quoted 9 lines
Are you suggesting this
combination:
IRQ on guest:
40: CPU0
41: CPU1
42: CPU2
43: CPU3 (all CPUs are on socket #0)
vhost:
thread #0: CPU0
Quoted 8 lines
thread #1: CPU1
thread #2: CPU2
thread #3: CPU3
qemu:
thread #0: CPU4
thread #1: CPU5
thread #2: CPU6
thread #3: CPU7 (all CPUs are on socket#1)
May be better to put vcpu threads and vhost threads on the same socket.
Also need to affine host interrupts.
Quoted 5 lines
netperf/netserver:
Run on CPUs 0-4 on both sidesThe reason I did not optimize anything from user space is because I felt showing the default works reasonably well is important.
Definitely. Heavy tuning is not a useful path for general end users. We need to make sure the the scheduler is able to arrive at the optimal layout without pinning (but perhaps with hints).
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Avi Kivity <[email protected]> wrote on 09/08/2010 02:58:21 PM:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
Why were vhost kernel changes required? Can't you just instantiate
more
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
vhost queues?
I did try using a single thread processing packets from multiple vq's on host, but the BW dropped beyond a certain number of sessions.
Oh - so the interface has not changed (which can be seen from the patch). That was my concern, I remembered that we planned for vhost-net to be multiqueue-ready.
The new guest and qemu code work with old vhost-net, just with reduced performance, yes?
Yes, I have tested new guest/qemu with old vhost but using #numtxqs=1 (or not passing any arguments at all to qemu to enable MQ). Giving numtxqs > 1 fails with ENOBUFS in vhost, since vhost_net_set_backend in the unmodified vhost checks for boundary overflow.
I have also tested running an unmodified guest with new vhost/qemu, but qemu should not specify numtxqs>1.
Quoted 25 lines
Quoted 17 lines
Are you suggesting this
combination:
IRQ on guest:40: CPU0 41: CPU1 42: CPU2 43: CPU3 (all CPUs are on socket #0) vhost: thread #0: CPU0 thread #1: CPU1 thread #2: CPU2 thread #3: CPU3 qemu: thread #0: CPU4 thread #1: CPU5 thread #2: CPU6 thread #3: CPU7 (all CPUs are on socket#1)May be better to put vcpu threads and vhost threads on the same socket.
Also need to affine host interrupts.
Quoted 3 lines
netperf/netserver:
Run on CPUs 0-4 on both sides
Quoted 6 lines
Quoted 2 lines
The reason I did not optimize anything from user space is because I felt showing the default works reasonably well is important.
Definitely. Heavy tuning is not a useful path for general end users. We need to make sure the the scheduler is able to arrive at the optimal layout without pinning (but perhaps with hints).
OK, I will see if I can get results with this.
Thanks for your suggestions,
- KK
Quoted 11 lines · On Wednesday 08 September 2010, Krishna Kumar2 wrote:
Quoted 2 lines
The new guest and qemu code work with old vhost-net, just with reduced performance, yes?
Yes, I have tested new guest/qemu with old vhost but using #numtxqs=1 (or not passing any arguments at all to qemu to enable MQ). Giving numtxqs > 1 fails with ENOBUFS in vhost, since
vhost_net_set_backendin the unmodified vhost checks for boundary overflow.I have also tested running an unmodified guest with new vhost/qemu, but qemu should not specify numtxqs>1.
Can you live migrate a new guest from new-qemu/new-kernel to old-qemu/old-kernel, new-qemu/old-kernel and old-qemu/new-kernel? If not, do we need to support all those cases?
Arnd
Quoted 2 lines · On Wednesday 08 September 2010, Krishna Kumar2 wrote:
Quoted 1 line
Quoted 1 line
The new guest and qemu code work with old vhost-net, just with
reduced
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
performance, yes?
Yes, I have tested new guest/qemu with old vhost but using #numtxqs=1 (or not passing any arguments at all to qemu to enable MQ). Giving numtxqs > 1 fails with ENOBUFS in vhost, since
vhost_net_set_backendin the unmodified vhost checks for boundary overflow.
Quoted 6 lines
Quoted 2 lines
I have also tested running an unmodified guest with new vhost/qemu, but qemu should not specify numtxqs>1.
Can you live migrate a new guest from new-qemu/new-kernel to old-qemu/old-kernel, new-qemu/old-kernel and old-qemu/new-kernel? If not, do we need to support all those cases?
I have not tried this, though I added some minimal code in virtio_net_load and virtio_net_save. I don't know what needs to be done exactly at this time. I forgot to put this in the "Next steps" list of things to do.
Thanks,
- KK
Quoted 14 lines · On Wednesday 08 September 2010, Krishna Kumar2 wrote:
Quoted 2 lines · On Wednesday 08 September 2010, Krishna Kumar2 wrote:
Quoted 1 line
Quoted 1 line
The new guest and qemu code work with old vhost-net, just with
reduced
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
performance, yes?
Yes, I have tested new guest/qemu with old vhost but using #numtxqs=1 (or not passing any arguments at all to qemu to enable MQ). Giving numtxqs > 1 fails with ENOBUFS in vhost, since
vhost_net_set_backendin the unmodified vhost checks for boundary overflow.I have also tested running an unmodified guest with new vhost/qemu, but qemu should not specify numtxqs>1.
Quoted 8 lines
Quoted 3 lines
Can you live migrate a new guest from new-qemu/new-kernel to old-qemu/old-kernel, new-qemu/old-kernel and old-qemu/new-kernel? If not, do we need to support all those cases?
I have not tried this, though I added some minimal code in
virtio_net_loadandvirtio_net_save. I don't know what needs to be done exactly at this time. I forgot to put this in the "Next steps" list of things to do.
I was mostly trying to find out if you think it should work or if there are specific reasons why it would not. E.g. when migrating to a machine that has an old qemu, the guest gets reduced to a single queue, but it's not clear to me how it can learn about this, or if it can get hidden by the outbound qemu.
Arnd
Arnd Bergmann <[email protected]> wrote on 09/09/2010 04:10:27 PM:
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Can you live migrate a new guest from new-qemu/new-kernel to old-qemu/old-kernel, new-qemu/old-kernel and old-qemu/new-kernel? If not, do we need to support all those cases?
I have not tried this, though I added some minimal code in
virtio_net_loadandvirtio_net_save. I don't know what needs to be done exactly at this time. I forgot to put this in the "Next steps" list of things to do.
Quoted 6 lines
I was mostly trying to find out if you think it should work or if there are specific reasons why it would not. E.g. when migrating to a machine that has an old qemu, the guest gets reduced to a single queue, but it's not clear to me how it can learn about this, or if it can get hidden by the outbound qemu.
I agree, I am also not sure how the old guest will handle this. Sorry about my ignorance on migration :(
Regards,
- KK
Michael S. Tsirkin
maintainerQuoted 40 lines · Krishna Kumar
Following patches implement Transmit mq in virtio-net. Also included is the user qemu changes.
1. This feature was first implemented with a single vhost. Testing showed 3-8% performance gain for upto 8 netperf sessions (and sometimes 16), but BW dropped with more sessions. However, implementing per-txq vhost improved BW significantly all the way to 128 sessions.
2. For this mq TX patch, 1 daemon is created for RX and 'n' daemons for the 'n' TXQ's, for a total of (n+1) daemons. The (subsequent) RX mq patch changes that to a total of 'n' daemons, where RX and TX vq's share 1 daemon.
3. Service Demand increases for TCP, but significantly improves for UDP.
4. Interoperability: Many combinations, but not all, of qemu, host, guest tested together.Enabling mq on virtio:
-----------------------When following options are passed to qemu:
- smp > 1
- vhost=on
- mq=on (new option, default:off)
then #txqueues = #cpus. The #txqueues can be changed by using an optional 'numtxqs' option. e.g. for a smp=4 guest:vhost=on,mq=on -> #txqueues = 4 vhost=on,mq=on,numtxqs=8 -> #txqueues = 8 vhost=on,mq=on,numtxqs=2 -> #txqueues = 2Performance (guest -> local host): -----------------------------------System configuration:
Host: 8 Intel Xeon, 8 GB memory
Guest: 4 cpus, 2 GB memory
All testing without any tuning, and TCP netperf with 64K I/O
_______________________________________________________________________________
Quoted 10 lines
TCP (#numtxqs=2) N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%) _______________________________________________________________________________ 4 26387 40716 (54.30) 20 28 (40.00) 86i 85 (-1.16) 8 24356 41843 (71.79) 88 129 (46.59) 372 362 (-2.68) 16 23587 40546 (71.89) 375 564 (50.40) 1558 1519 (-2.50) 32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722 (-14.52) 48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552 (-14.35) 64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173 (-9.66) 96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031 (10.74)
That's a significant hit in TCP SD. Is it caused by the imbalance between number of queues for TX and RX? Since you mention RX is complete, maybe measure with a balanced TX/RX?
Quoted 11 lines
_______________________________________________________________________________
UDP (#numtxqs=8) N# BW1 BW2 (%) SD1 SD2 (%) __________________________________________________________ 4 29836 56761 (90.24) 67 63 (-5.97) 8 27666 63767 (130.48) 326 265 (-18.71) 16 25452 60665 (138.35) 1396 1269 (-9.09) 32 26172 63491 (142.59) 5617 4202 (-25.19) 48 26146 64629 (147.18) 12813 9316 (-27.29) 64 25575 65448 (155.90) 23063 16346 (-29.12) 128 26454 63772 (141.06) 91054 85051 (-6.59)
Quoted 8 lines
__________________________________________________________
N#: Number of netperf sessions, 90 sec runs BW1,SD1,RSD1: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for original code
BW2,SD2,RSD2: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for new code. e.g. BW2=40716 means average BW2 was 20358 mbps.
What happens with a single netperf?
host -> guest performance with TCP and small packet speed are also worth measuring.
Quoted 7 lines
Next steps: -----------1. mq RX patch is also complete - plan to submit once TX is OK.
2. Cache-align data structures: I didn't see any BW/SD improvement after making the sq's (and similarly for vhost) cache-aligned statically:
Quoted 6 lines
struct virtnet_info {
...
struct send_queue sq[16] ____cacheline_aligned_in_smp;
...
};At some level, host/guest communication is easy in that we don't really care which queue is used. I would like to give some thought (and testing) to how is this going to work with a real NIC card and packet steering at the backend.
Any idea?
Quoted 9 lines
Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts CPU0 CPU1 CPU2 CPU3 40: 0 0 0 0 PCI-MSI-edge virtio0-config 41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input 42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0 43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1 44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2 45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3
Does this mean each interrupt is constantly bouncing between CPUs?
Quoted 4 lines
Review/feedback appreciated.
Signed-off-by Krishna Kumar <[email protected]>---
"Michael S. Tsirkin" <[email protected]> wrote on 09/08/2010 01:40:11 PM:
Quoted 1 line
_______________________________________________________________________________
Quoted 2 lines
Quoted 2 lines
TCP (#numtxqs=2)N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2
(%)
Quoted 2 lines
Quoted 1 line
_______________________________________________________________________________
Quoted 1 line
Quoted 1 line
4 26387 40716 (54.30) 20 28 (40.00) 86i 85
(-1.16)
Quoted 1 line
Quoted 1 line
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
Quoted 1 line
Quoted 1 line
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519
(-2.50)
Quoted 1 line
Quoted 1 line
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722
(-14.52)
Quoted 1 line
Quoted 1 line
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552
(-14.35)
Quoted 1 line
Quoted 1 line
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173
(-9.66)
Quoted 1 line
Quoted 1 line
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031
(10.74)
Quoted 4 lines
That's a significant hit in TCP SD. Is it caused by the imbalance between number of queues for TX and RX? Since you mention RX is complete, maybe measure with a balanced TX/RX?
Yes, I am not sure why it is so high. I found the same with #RX=#TX too. As a hack, I tried ixgbe without MQ (set "indices=1" before calling alloc_etherdev_mq, not sure if that is entirely correct) - here too SD worsened by around 40%. I can't explain it, since the virtio-net driver runs lock free once sch_direct_xmit gets HARD_TX_LOCK for the specific txq. Maybe the SD calculation is not strictly correct since
more threads are now running parallel and load is higher? Eg, if you compare SD between
#netperfs = 8 vs 16 for original code (cut-n-paste relevant columns only) ...
N# BW SD
8 24356 88
16 23587 375
... SD has increased more than 4 times for the same BW.
Quoted 3 lines
What happens with a single netperf?
host -> guest performance with TCP and small packet speed are also worth measuring.
OK, I will do this and send the results later today.
Quoted 5 lines
At some level, host/guest communication is easy in that we don't really care which queue is used. I would like to give some thought (and testing) to how is this going to work with a real NIC card and packet steering at the backend.
Any idea?
I have done a little testing with guest -> remote server both using a bridge and with macvtap (mq is required only for rx). I didn't understand what you mean by packet steering though, is it whether packets go out of the NIC on different queues? If so, I verified that is the case by putting a counter and displaying through /debug interface on the host. dev_queue_xmit on the host handles it by calling dev_pick_tx().
Quoted 11 lines
Quoted 9 lines
Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts CPU0 CPU1 CPU2 CPU3 40: 0 0 0 0 PCI-MSI-edge virtio0-config 41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input 42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0 43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1 44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2 45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3Does this mean each interrupt is constantly bouncing between CPUs?
Yes. I didn't do *any* tuning for the tests. The only "tuning" was to use 64K IO size with netperf. When I ran default netperf (16K), I got a little lesser improvement in BW and worse(!) SD than with 64K.
Thanks,
- KK
Michael S. Tsirkin
maintainerQuoted 24 lines · On Wed, Sep 08, 2010 at 02:53:03PM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin" <[email protected]> wrote on 09/08/2010 01:40:11 PM:
Quoted 1 line
_______________________________________________________________________________
Quoted 2 lines
Quoted 2 lines
TCP (#numtxqs=2)N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2
(%)
Quoted 2 lines
Quoted 1 line
_______________________________________________________________________________
Quoted 1 line
Quoted 1 line
4 26387 40716 (54.30) 20 28 (40.00) 86i 85
(-1.16)
Quoted 1 line
Quoted 1 line
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
Quoted 1 line
Quoted 1 line
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519
(-2.50)
Quoted 1 line
Quoted 1 line
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722
(-14.52)
Quoted 1 line
Quoted 1 line
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552
(-14.35)
Quoted 1 line
Quoted 1 line
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173
(-9.66)
Quoted 8 lines
Quoted 1 line
Quoted 1 line
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031
(10.74)
Quoted 4 lines
That's a significant hit in TCP SD. Is it caused by the imbalance between number of queues for TX and RX? Since you mention RX is complete, maybe measure with a balanced TX/RX?
Yes, I am not sure why it is so high.
Any errors at higher levels? Are any packets reordered?
Quoted 58 lines
I found the same with #RX=#TX
too. As a hack, I tried ixgbe without MQ (set "indices=1" before callingalloc_etherdev_mq, not sure if that is entirely correct) - here too SD worsened by around 40%. I can't explain it, since the virtio-net driver runs lock free oncesch_direct_xmitgetsHARD_TX_LOCKfor the specific txq. Maybe the SD calculation is not strictly correct since
more threads are now running parallel and load is higher? Eg, if you compare SD between
#netperfs = 8 vs 16 for original code (cut-n-paste relevant columns only) ...N# BW SD
8 24356 88
16 23587 375... SD has increased more than 4 times for the same BW.
Quoted 3 lines
What happens with a single netperf?
host -> guest performance with TCP and small packet speed are also worth measuring.OK, I will do this and send the results later today.
Quoted 5 lines
At some level, host/guest communication is easy in that we don't really care which queue is used. I would like to give some thought (and testing) to how is this going to work with a real NIC card and packet steering at the backend.
Any idea?I have done a little testing with guest -> remote server both using a bridge and with macvtap (mq is required only for rx). I didn't understand what you mean by packet steering though, is it whether packets go out of the NIC on different queues? If so, I verified that is the case by putting a counter and displaying through /debug interface on the host.
dev_queue_xmiton the host handles it by callingdev_pick_tx().Quoted 11 lines
Quoted 9 lines
Guest interrupts for a 4 TXQ device after a 5 min test:
# egrep "virtio0|CPU" /proc/interrupts CPU0 CPU1 CPU2 CPU3 40: 0 0 0 0 PCI-MSI-edge virtio0-config 41: 126955 126912 126505 126940 PCI-MSI-edge virtio0-input 42: 108583 107787 107853 107716 PCI-MSI-edge virtio0-output.0 43: 300278 297653 299378 300554 PCI-MSI-edge virtio0-output.1 44: 372607 374884 371092 372011 PCI-MSI-edge virtio0-output.2 45: 162042 162261 163623 162923 PCI-MSI-edge virtio0-output.3Does this mean each interrupt is constantly bouncing between CPUs?
Yes. I didn't do *any* tuning for the tests. The only "tuning" was to use 64K IO size with netperf. When I ran default netperf (16K), I got a little lesser improvement in BW and worse(!) SD than with 64K.
Thanks,
- KK
"Michael S. Tsirkin" <[email protected]> wrote on 09/08/2010 04:18:33 PM:
Quoted 1 line
_______________________________________________________________________________
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
TCP (#numtxqs=2)N# BW1 BW2 (%) SD1 SD2 (%) RSD1
RSD2
Quoted 5 lines
Quoted 4 lines
(%)
Quoted 2 lines
Quoted 1 line
_______________________________________________________________________________
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
4 26387 40716 (54.30) 20 28 (40.00) 86i 85
(-1.16)
Quoted 1 line
Quoted 1 line
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
Quoted 1 line
Quoted 1 line
16 23587 40546 (71.89) 375 564 (50.40) 1558
1519
Quoted 2 lines
Quoted 2 lines
(-2.50)
Quoted 1 line
Quoted 1 line
32 22927 39490 (72.24) 1617 2171 (34.26) 6694
5722
Quoted 2 lines
Quoted 2 lines
(-14.52)
Quoted 1 line
Quoted 1 line
48 23067 39238 (70.10) 3931 5170 (31.51) 15823
13552
Quoted 2 lines
Quoted 2 lines
(-14.35)
Quoted 1 line
Quoted 1 line
64 22927 38750 (69.01) 7142 9914 (38.81) 28972
26173
Quoted 2 lines
Quoted 2 lines
(-9.66)
Quoted 1 line
Quoted 1 line
96 22568 38520 (70.68) 16258 27844 (71.26) 65944
73031
Quoted 3 lines
Quoted 3 lines
(10.74)
Quoted 2 lines
That's a significant hit in TCP SD. Is it caused by the imbalance
between
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
number of queues for TX and RX? Since you mention RX is complete, maybe measure with a balanced TX/RX?
Yes, I am not sure why it is so high.
Any errors at higher levels? Are any packets reordered?
I haven't seen any messages logged, and retransmission is similar to non-mq case. Device also has no errors/dropped packets. Anything else I should look for?
On the host:
# ifconfig vnet0
vnet0 Link encap:Ethernet HWaddr 9A:9D:99:E1:CA:CE
inet6 addr: fe80::989d:99ff:fee1:cace/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5090371 errors:0 dropped:0 overruns:0 frame:0
TX packets:5054616 errors:0 dropped:0 overruns:65 carrier:0
collisions:0 txqueuelen:500
RX bytes:237793761392 (221.4 GiB) TX bytes:333630070 (318.1 MiB)
# netstat -s |grep -i retrans
1310 segments retransmited
35 times recovered from packet loss due to fast retransmit
1 timeouts after reno fast retransmit
41 fast retransmits
1236 retransmits in slow startSo retranmissions are 0.025% of total packets received from the guest.
Thanks,
- KK
"Michael S. Tsirkin" <[email protected]> wrote on 09/08/2010 01:40:11 PM:
Quoted 1 line
_______________________________________________________________________________
Quoted 19 lines
Quoted 10 lines
UDP (#numtxqs=8) N# BW1 BW2 (%) SD1 SD2 (%) __________________________________________________________ 4 29836 56761 (90.24) 67 63 (-5.97) 8 27666 63767 (130.48) 326 265 (-18.71) 16 25452 60665 (138.35) 1396 1269 (-9.09) 32 26172 63491 (142.59) 5617 4202 (-25.19) 48 26146 64629 (147.18) 12813 9316 (-27.29) 64 25575 65448 (155.90) 23063 16346 (-29.12) 128 26454 63772 (141.06) 91054 85051 (-6.59)Quoted 8 lines
__________________________________________________________
N#: Number of netperf sessions, 90 sec runs BW1,SD1,RSD1: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for original code
BW2,SD2,RSD2: Bandwidth (sum across 2 runs in mbps), SD and Remote
SD for new code. e.g. BW2=40716 means average BW2 was 20358 mbps.
Quoted 3 lines
What happens with a single netperf?
host -> guest performance with TCP and small packet speed are also worth measuring.
Guest -> Host (single netperf):
I am getting a drop of almost 20%. I am trying to figure out why.
Host -> guest (single netperf):
I am getting an improvement of almost 15%. Again - unexpected.
Guest -> Host TCP_RR: I get an average 7.4% increase in #packets for runs upto 128 sessions. With fewer netperf (under 8), there was a drop of 3-7% in #packets, but beyond that, the #packets improved significantly to give an average improvement of 7.4%.
So it seems that fewer sessions is having negative effect for some reason on the tx side. The code path in virtio-net has not changed much, so the drop in some cases is quite unexpected.
Thanks,
- KK
A message that is not in the archive (sent off-list or not yet received): OF70542242.6CAA236A-ON65257798.0044A4E0-65257798.005C0E7C@LocalDomain
Quoted 1 line
Krishna Kumar2/India/IBM wrote on 09/08/2010 10:17:49 PM:
Some more results and likely cause for single netperf degradation below.
Quoted 7 lines
Guest -> Host (single netperf):
I am getting a drop of almost 20%. I am trying to figure out why.Host -> guest (single netperf):
I am getting an improvement of almost 15%. Again - unexpected.
Quoted 8 lines
Guest -> Host
TCP_RR: I get an average 7.4% increase in #packets for runs upto 128 sessions. With fewer netperf (under 8), there was a drop of 3-7% in #packets, but beyond that, the #packets improved significantly to give an average improvement of 7.4%.So it seems that fewer sessions is having negative effect for some reason on the tx side. The code path in virtio-net has not changed much, so the drop in some cases is quite unexpected.
The drop for the single netperf seems to be due to multiple vhost. I changed the patch to start *single* vhost:
Guest -> Host (1 netperf, 64K): BW: 10.79%, SD: -1.45%
Guest -> Host (1 netperf) : Latency: -3%, SD: 3.5%
Single vhost performs well but hits the barrier at 16 netperf sessions:
SINGLE vhost (Guest -> Host):
1 netperf: BW: 10.7% SD: -1.4%
4 netperfs: BW: 3% SD: 1.4%
8 netperfs: BW: 17.7% SD: -10%
16 netperfs: BW: 4.7% SD: -7.0%
32 netperfs: BW: -6.1% SD: -5.7%BW and SD both improves (guest multiple txqs help). For 32 netperfs, SD improves.
But with multiple vhosts, guest is able to send more packets and BW increases much more (SD too increases, but I think that is expected). From the earlier results:
N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%)
_______________________________________________________________________________
4 26387 40716 (54.30) 20 28 (40.00) 86 85
(-1.16)
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519
(-2.50)
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722
(-14.52)
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552
(-14.35)
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173
(-9.66)
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031
(10.74)
_______________________________________________________________________________
(All tests were done without any tuning)
Quoted 1 line
From my testing:
1. Single vhost improves mq guest performance upto 16 netperfs but degrades after that.
2. Multiple vhost degrades single netperf guest performance, but significantly improves performance for any number of netperf sessions.
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
2. I (re-)modified the patch to share RX with TX[0]. The performance drop is the same, but the reason is the guest is not using txq[0] in most cases (dev_pick_tx), so vhost's rx and tx are running on different threads. But whenever the guest uses txq[0], only one vhost runs and the performance is similar to original.
I went back to my *submitted* patch and started a guest with numtxq=16 and pinned every vhost to cpus #0&1. Now whether guest used txq[0] or txq[n], the performance is similar or better (between 10-27% across 10 runs) than original code. Also, -6% to -24% improvement in SD.
I will start a full test run of original vs submitted code with minimal tuning (Avi also suggested the same), and re-send. Please let me know if you need any other data.
Thanks,
- KK
Quoted 17 lines · On 9/9/2010 2:45 AM, Krishna Kumar2 wrote:
Quoted 1 line
Krishna Kumar2/India/IBM wrote on 09/08/2010 10:17:49 PM:
Some more results and likely cause for single netperf degradation below.
Quoted 12 lines
Guest -> Host (single netperf):
I am getting a drop of almost 20%. I am trying to figure out why.Host -> guest (single netperf):
I am getting an improvement of almost 15%. Again - unexpected.Guest -> Host
TCP_RR: I get an average 7.4% increase in #packets for runs upto 128 sessions. With fewer netperf (under 8), there was a drop of 3-7% in #packets, but beyond that, the #packets improved significantly to give an average improvement of 7.4%.
Quoted 8 lines
Quoted 3 lines
So it seems that fewer sessions is having negative effect for some reason on the tx side. The code path in virtio-net has not changed much, so the drop in some cases is quite unexpected.
The drop for the single netperf seems to be due to multiple vhost. I changed the patch to start *single* vhost:
Guest -> Host (1 netperf, 64K): BW: 10.79%, SD: -1.45%
Guest -> Host (1 netperf) : Latency: -3%, SD: 3.5%
I remember seeing similar issue when using a separate vhost thread for TX and RX queues. Basically, we should have the same vhost thread process a TCP flow in both directions. I guess this allows the data and ACKs to be processed in sync.
Thanks
Sridhar
Quoted 75 lines
Single vhost performs well but hits the barrier at 16 netperf sessions:
SINGLE vhost (Guest -> Host):
1 netperf: BW: 10.7% SD: -1.4% 4 netperfs: BW: 3% SD: 1.4% 8 netperfs: BW: 17.7% SD: -10% 16 netperfs: BW: 4.7% SD: -7.0% 32 netperfs: BW: -6.1% SD: -5.7%BW and SD both improves (guest multiple txqs help). For 32 netperfs, SD improves.
But with multiple vhosts, guest is able to send more packets and BW increases much more (SD too increases, but I think that is expected). From the earlier results:
N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%)
_______________________________________________________________________________
4 26387 40716 (54.30) 20 28 (40.00) 86 85
(-1.16)
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519
(-2.50)
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722
(-14.52)
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552
(-14.35)
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173
(-9.66)
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031
(10.74)
_______________________________________________________________________________
(All tests were done without any tuning)From my testing:
1. Single vhost improves mq guest performance upto 16 netperfs but degrades after that.
2. Multiple vhost degrades single netperf guest performance, but significantly improves performance for any number of netperf sessions.Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
2. I (re-)modified the patch to share RX with TX[0]. The performance drop is the same, but the reason is the guest is not using txq[0] in most cases (dev_pick_tx), so vhost's rx and tx are running on different threads. But whenever the guest uses txq[0], only one vhost runs and the performance is similar to original.I went back to my *submitted* patch and started a guest with numtxq=16 and pinned every vhost to cpus #0&1. Now whether guest used txq[0] or txq[n], the performance is similar or better (between 10-27% across 10 runs) than original code. Also, -6% to -24% improvement in SD.
I will start a full test run of original vs submitted code with minimal tuning (Avi also suggested the same), and re-send. Please let me know if you need any other data.
Thanks,
- KK
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sridhar Samudrala <[email protected]> wrote on 09/10/2010 04:30:24 AM:
Quoted 6 lines
I remember seeing similar issue when using a separate vhost thread for TX and
RX queues. Basically, we should have the same vhost thread process a TCP flow
in both directions. I guess this allows the data and ACKs to be processed in sync.
I was trying that by sharing threads between rx and tx[0], but that didn't work either since guest rarely picks txq=0. I was able to get reasonable single stream performance by pinning vhosts to the same cpu.
Thanks,
- KK
Michael S. Tsirkin
maintainerQuoted 37 lines · On Thu, Sep 09, 2010 at 03:15:53PM +0530, Krishna Kumar2 wrote:
Quoted 1 line
Krishna Kumar2/India/IBM wrote on 09/08/2010 10:17:49 PM:
Some more results and likely cause for single netperf degradation below.
Quoted 7 lines
Guest -> Host (single netperf):
I am getting a drop of almost 20%. I am trying to figure out why.Host -> guest (single netperf):
I am getting an improvement of almost 15%. Again - unexpected.Quoted 8 lines
Guest -> Host
TCP_RR: I get an average 7.4% increase in #packets for runs upto 128 sessions. With fewer netperf (under 8), there was a drop of 3-7% in #packets, but beyond that, the #packets improved significantly to give an average improvement of 7.4%.So it seems that fewer sessions is having negative effect for some reason on the tx side. The code path in virtio-net has not changed much, so the drop in some cases is quite unexpected.
The drop for the single netperf seems to be due to multiple vhost. I changed the patch to start *single* vhost:
Guest -> Host (1 netperf, 64K): BW: 10.79%, SD: -1.45%
Guest -> Host (1 netperf) : Latency: -3%, SD: 3.5%Single vhost performs well but hits the barrier at 16 netperf sessions:
SINGLE vhost (Guest -> Host):
1 netperf: BW: 10.7% SD: -1.4% 4 netperfs: BW: 3% SD: 1.4% 8 netperfs: BW: 17.7% SD: -10% 16 netperfs: BW: 4.7% SD: -7.0% 32 netperfs: BW: -6.1% SD: -5.7%
Quoted 6 lines
BW and SD both improves (guest multiple txqs help). For 32 netperfs, SD improves.
But with multiple vhosts, guest is able to send more packets and BW increases much more (SD too increases, but I think that is expected).
Why is this expected?
Quoted 29 lines
From the earlier results:
N# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%)
_______________________________________________________________________________
4 26387 40716 (54.30) 20 28 (40.00) 86 85
(-1.16)
8 24356 41843 (71.79) 88 129 (46.59) 372 362
(-2.68)
16 23587 40546 (71.89) 375 564 (50.40) 1558 1519
(-2.50)
32 22927 39490 (72.24) 1617 2171 (34.26) 6694 5722
(-14.52)
48 23067 39238 (70.10) 3931 5170 (31.51) 15823 13552
(-14.35)
64 22927 38750 (69.01) 7142 9914 (38.81) 28972 26173
(-9.66)
96 22568 38520 (70.68) 16258 27844 (71.26) 65944 73031
(10.74)
_______________________________________________________________________________
(All tests were done without any tuning)Quoted 1 line
From my testing:
1. Single vhost improves mq guest performance upto 16 netperfs but degrades after that.
2. Multiple vhost degrades single netperf guest performance, but significantly improves performance for any number of netperf sessions.
Quoted 6 lines
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
Right. With TCP I think we are better off handling TX and RX for a socket by the same vhost, so that packet and its ack are handled by the same thread. Is this what happens with RX multiqueue patch? How do we select an RX queue to put the packet on?
Quoted 21 lines
2. I (re-)modified the patch to share RX with TX[0]. The performance drop is the same, but the reason is the guest is not using txq[0] in most cases (
dev_pick_tx), so vhost's rx and tx are running on different threads. But whenever the guest uses txq[0], only one vhost runs and the performance is similar to original.I went back to my *submitted* patch and started a guest with numtxq=16 and pinned every vhost to cpus #0&1. Now whether guest used txq[0] or txq[n], the performance is similar or better (between 10-27% across 10 runs) than original code. Also, -6% to -24% improvement in SD.
I will start a full test run of original vs submitted code with minimal tuning (Avi also suggested the same), and re-send. Please let me know if you need any other data.
Thanks,
- KK
"Michael S. Tsirkin" <[email protected]> wrote on 09/12/2010 05:10:25 PM:
Quoted 9 lines
Quoted 9 lines
SINGLE vhost (Guest -> Host):
1 netperf: BW: 10.7% SD: -1.4% 4 netperfs: BW: 3% SD: 1.4% 8 netperfs: BW: 17.7% SD: -10% 16 netperfs: BW: 4.7% SD: -7.0% 32 netperfs: BW: -6.1% SD: -5.7%BW and SD both improves (guest multiple txqs help). For 32 netperfs, SD improves.
Quoted 5 lines
Quoted 3 lines
But with multiple vhosts, guest is able to send more packets and BW increases much more (SD too increases, but I think that is expected).
Why is this expected?
Results with the original kernel:
_____________________________
# BW SD RSD
______________________________
1 20903 1 6 2 21963 6 25 4 22042 23 102 8 21674 97 419 16 22281 379 1663 24 22521 857 3748 32 22976 1528 6594 40 23197 2390 10239 48 22973 3542 15074 64 23809 6486 27244 80 23564 10169 43118 96 22977 14954 62948 128 23649 27067 113892
________________________________
With higher number of threads running in parallel, SD increased. In this case most threads run in parallel only till __dev_xmit_skb (#numtxqs=1). With mq TX patch, higher number of threads run in parallel through ndo_start_xmit. I *think* the increase in SD is to do with higher # of threads running for larger code path
Quoted 1 line
From the numbers I posted with the patch (cut-n-paste
only the % parts), BW increased much more than the SD, sometimes more than twice the increase in SD.
N# BW% SD% RSD% 4 54.30 40.00 -1.16 8 71.79 46.59 -2.68 16 71.89 50.40 -2.50 32 72.24 34.26 -14.52 48 70.10 31.51 -14.35 64 69.01 38.81 -9.66 96 70.68 71.26 10.74
I also think SD calculation gets skewed for guest->local host testing. For this test, I ran a guest with numtxqs=16. The first result below is with my patch, which creates 16 vhosts. The second result is with a modified patch which creates only 2 vhosts (testing with #netperfs = 64):
#vhosts BW% SD% RSD% 16 20.79 186.01 149.74 2 30.89 34.55 18.44
The remote SD increases with the number of vhost threads, but that number seems to correlate with guest SD. So though BW% increased slightly from 20% to 30%, SD fell drastically from 186% to 34%. I think it could be a calculation skew with host SD, which also fell from 150% to 18%.
I am planning to submit 2nd patch rev with restricted number of vhosts.
Quoted 7 lines
Quoted 6 lines
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
Quoted 5 lines
Right. With TCP I think we are better off handling TX and RX for a socket by the same vhost, so that packet and its ack are handled by the same thread. Is this what happens with RX multiqueue patch? How do we select an RX queue to put the packet on?
My (unsubmitted) RX patch doesn't do this yet, that is something I will check.
Thanks,
- KK
Michael S. Tsirkin
maintainerQuoted 42 lines · On Mon, Sep 13, 2010 at 09:42:22AM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin" <[email protected]> wrote on 09/12/2010 05:10:25 PM:
Quoted 9 lines
Quoted 9 lines
SINGLE vhost (Guest -> Host):
1 netperf: BW: 10.7% SD: -1.4% 4 netperfs: BW: 3% SD: 1.4% 8 netperfs: BW: 17.7% SD: -10% 16 netperfs: BW: 4.7% SD: -7.0% 32 netperfs: BW: -6.1% SD: -5.7%BW and SD both improves (guest multiple txqs help). For 32 netperfs, SD improves.
Quoted 5 lines
Quoted 3 lines
But with multiple vhosts, guest is able to send more packets and BW increases much more (SD too increases, but I think that is expected).
Why is this expected?
Results with the original kernel:
_____________________________
# BW SD RSD
______________________________1 20903 1 6 2 21963 6 25 4 22042 23 102 8 21674 97 419 16 22281 379 1663 24 22521 857 3748 32 22976 1528 6594 40 23197 2390 10239 48 22973 3542 15074 64 23809 6486 27244 80 23564 10169 43118 96 22977 14954 62948 128 23649 27067 113892________________________________
With higher number of threads running in parallel, SD increased. In this case most threads run in parallel only till
__dev_xmit_skb(#numtxqs=1). With mq TX patch, higher number of threads run in parallel throughndo_start_xmit. I *think* the increase in SD is to do with higher # of threads running for larger code path
Quoted 3 lines
Quoted 1 line
From the numbers I posted with the patch (cut-n-paste
only the % parts), BW increased much more than the SD, sometimes more than twice the increase in SD.
Service demand is BW/CPU, right? So if BW goes up by 50% and SD by 40%, this means that CPU more than doubled.
Quoted 11 lines
N# BW% SD% RSD% 4 54.30 40.00 -1.16 8 71.79 46.59 -2.68 16 71.89 50.40 -2.50 32 72.24 34.26 -14.52 48 70.10 31.51 -14.35 64 69.01 38.81 -9.66 96 70.68 71.26 10.74I also think SD calculation gets skewed for
guest->localhost testing.
If it's broken, let's fix it?
Quoted 4 lines
For this test, I ran a guest with numtxqs=16. The first result below is with my patch, which creates 16 vhosts. The second result is with a modified patch which creates only 2 vhosts (testing with #netperfs = 64):
My guess is it's not a good idea to have more TX VQs than guest CPUs.
I realize for management it's easier to pass in a single vhost fd, but just for testing it's probably easier to add code in userspace to open /dev/vhost multiple times.
Quoted 10 lines
#vhosts BW% SD% RSD% 16 20.79 186.01 149.74 2 30.89 34.55 18.44The remote SD increases with the number of vhost threads, but that number seems to correlate with guest SD. So though BW% increased slightly from 20% to 30%, SD fell drastically from 186% to 34%. I think it could be a calculation skew with host SD, which also fell from 150% to 18%.
I think by default netperf looks in /proc/stat for CPU utilization data:
so host CPU utilization will include the guest CPU, I think?
I would go further and claim that for host/guest TCP CPU utilization and SD should always be identical. Makes sense?
Quoted 17 lines
I am planning to submit 2nd patch rev with restricted number of vhosts.
Quoted 7 lines
Quoted 6 lines
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
Quoted 5 lines
Right. With TCP I think we are better off handling TX and RX for a socket by the same vhost, so that packet and its ack are handled by the same thread. Is this what happens with RX multiqueue patch? How do we select an RX queue to put the packet on?
Quoted 6 lines
My (unsubmitted) RX patch doesn't do this yet, that is something I will check.
Thanks,
- KK
You'll want to work on top of net-next, I think there's RX flow filtering work going on there.
Signature · 1 line
MST
"Michael S. Tsirkin" <[email protected]> wrote on 09/13/2010 05:20:55 PM:
Quoted 25 lines
Quoted 25 lines
Results with the original kernel:
_____________________________
# BW SD RSD
______________________________1 20903 1 6 2 21963 6 25 4 22042 23 102 8 21674 97 419 16 22281 379 1663 24 22521 857 3748 32 22976 1528 6594 40 23197 2390 10239 48 22973 3542 15074 64 23809 6486 27244 80 23564 10169 43118 96 22977 14954 62948 128 23649 27067 113892________________________________
With higher number of threads running in parallel, SD increased. In this case most threads run in parallel only till
__dev_xmit_skb(#numtxqs=1). With mq TX patch, higher number of threads run in parallel throughndo_start_xmit. I *think* the increase in SD is to do with higher # of threads running for larger code path
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
From the numbers I posted with the patch (cut-n-paste
only the % parts), BW increased much more than the SD, sometimes more than twice the increase in SD.
Service demand is BW/CPU, right? So if BW goes up by 50% and SD by 40%, this means that CPU more than doubled.
I think the SD calculation might be more complicated, I think it does it based on adding up averages sampled and stored during the run. But, I still don't see how CPU can double?? e.g.
BW: 1000 -> 1500 (50%) SD: 100 -> 140 (40%) CPU: 10 -> 10.71 (7.1%)
Quoted 12 lines
Quoted 11 lines
N# BW% SD% RSD% 4 54.30 40.00 -1.16 8 71.79 46.59 -2.68 16 71.89 50.40 -2.50 32 72.24 34.26 -14.52 48 70.10 31.51 -14.35 64 69.01 38.81 -9.66 96 70.68 71.26 10.74I also think SD calculation gets skewed for
guest->localhost testing.
Quoted 8 lines
If it's broken, let's fix it?
Quoted 4 lines
For this test, I ran a guest with numtxqs=16. The first result below is with my patch, which creates 16 vhosts. The second result is with a modified patch which creates only 2 vhosts (testing with #netperfs = 64):
My guess is it's not a good idea to have more TX VQs than guest CPUs.
Definitely, I will try to run tomorrow with more reasonable values, also will test with my second version of the patch that creates restricted number of vhosts and post results.
Quoted 9 lines
I realize for management it's easier to pass in a single vhost fd, but just for testing it's probably easier to add code in userspace to open
/dev/vhostmultiple times.Quoted 5 lines
#vhosts BW% SD% RSD% 16 20.79 186.01 149.74 2 30.89 34.55 18.44
Quoted 8 lines
Quoted 5 lines
The remote SD increases with the number of vhost threads, but that number seems to correlate with guest SD. So though BW% increased slightly from 20% to 30%, SD fell drastically from 186% to 34%. I think it could be a calculation skew with host SD, which also fell from 150% to 18%.
I think by default netperf looks in
/proc/statfor CPU utilization data:
so host CPU utilization will include the guest CPU, I think?
It appears that way to me too, but the data above seems to suggest the opposite...
Quoted 3 lines
I would go further and claim that for host/guest TCP CPU utilization and SD should always be identical. Makes sense?
It makes sense to me, but once again I am not sure how SD is really done, or whether it is linear to CPU. Cc'ing Rick in case he can comment....
Quoted 21 lines
Quoted 21 lines
I am planning to submit 2nd patch rev with restricted number of vhosts.
Quoted 7 lines
Quoted 6 lines
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
Quoted 5 lines
Right. With TCP I think we are better off handling TX and RX for a socket by the same vhost, so that packet and its ack are handled by the same thread. Is this what happens with RX multiqueue patch? How do we select an RX queue to put the packet on?
My (unsubmitted) RX patch doesn't do this yet, that is something I will check.
Quoted 6 lines
Quoted 3 lines
Thanks,
- KK
You'll want to work on top of net-next, I think there's RX flow filtering work going on there.
Thanks Michael, I will follow up on that for the RX patch, plus your suggestion on tying RX with TX.
Thanks,
- KK
Michael S. Tsirkin
maintainerQuoted 34 lines · On Mon, Sep 13, 2010 at 09:53:40PM +0530, Krishna Kumar2 wrote:
"Michael S. Tsirkin" <[email protected]> wrote on 09/13/2010 05:20:55 PM:
Quoted 25 lines
Quoted 25 lines
Results with the original kernel:
_____________________________
# BW SD RSD
______________________________1 20903 1 6 2 21963 6 25 4 22042 23 102 8 21674 97 419 16 22281 379 1663 24 22521 857 3748 32 22976 1528 6594 40 23197 2390 10239 48 22973 3542 15074 64 23809 6486 27244 80 23564 10169 43118 96 22977 14954 62948 128 23649 27067 113892________________________________
With higher number of threads running in parallel, SD increased. In this case most threads run in parallel only till
__dev_xmit_skb(#numtxqs=1). With mq TX patch, higher number of threads run in parallel throughndo_start_xmit. I *think* the increase in SD is to do with higher # of threads running for larger code pathQuoted 6 lines
Quoted 3 lines
Quoted 1 line
From the numbers I posted with the patch (cut-n-paste
only the % parts), BW increased much more than the SD, sometimes more than twice the increase in SD.
Service demand is BW/CPU, right? So if BW goes up by 50% and SD by 40%, this means that CPU more than doubled.
Quoted 7 lines
I think the SD calculation might be more complicated, I think it does it based on adding up averages sampled and stored during the run. But, I still don't see how CPU can double?? e.g.
BW: 1000 -> 1500 (50%) SD: 100 -> 140 (40%) CPU: 10 -> 10.71 (7.1%)
Hmm. Time to look at the source. Which netperf version did you use?
Quoted 46 lines
Quoted 12 lines
Quoted 11 lines
N# BW% SD% RSD% 4 54.30 40.00 -1.16 8 71.79 46.59 -2.68 16 71.89 50.40 -2.50 32 72.24 34.26 -14.52 48 70.10 31.51 -14.35 64 69.01 38.81 -9.66 96 70.68 71.26 10.74I also think SD calculation gets skewed for
guest->localhost testing.Quoted 8 lines
If it's broken, let's fix it?
Quoted 4 lines
For this test, I ran a guest with numtxqs=16. The first result below is with my patch, which creates 16 vhosts. The second result is with a modified patch which creates only 2 vhosts (testing with #netperfs = 64):
My guess is it's not a good idea to have more TX VQs than guest CPUs.
Definitely, I will try to run tomorrow with more reasonable values, also will test with my second version of the patch that creates restricted number of vhosts and post results.
Quoted 9 lines
I realize for management it's easier to pass in a single vhost fd, but just for testing it's probably easier to add code in userspace to open
/dev/vhostmultiple times.Quoted 5 lines
#vhosts BW% SD% RSD% 16 20.79 186.01 149.74 2 30.89 34.55 18.44Quoted 8 lines
Quoted 5 lines
The remote SD increases with the number of vhost threads, but that number seems to correlate with guest SD. So though BW% increased slightly from 20% to 30%, SD fell drastically from 186% to 34%. I think it could be a calculation skew with host SD, which also fell from 150% to 18%.
I think by default netperf looks in
/proc/statfor CPU utilization data:
so host CPU utilization will include the guest CPU, I think?It appears that way to me too, but the data above seems to suggest the opposite...
Quoted 7 lines
Quoted 3 lines
I would go further and claim that for host/guest TCP CPU utilization and SD should always be identical. Makes sense?
It makes sense to me, but once again I am not sure how SD is really done, or whether it is linear to CPU. Cc'ing Rick in case he can comment....
Me neither. I should rephrase: I think we should always use host CPU utilization always.
Quoted 39 lines
Quoted 21 lines
Quoted 21 lines
I am planning to submit 2nd patch rev with restricted number of vhosts.
Quoted 7 lines
Quoted 6 lines
Likely cause for the 1 stream degradation with multiple vhost patch:
1. Two vhosts run handling the RX and TX respectively. I think the issue is related to cache ping-pong esp since these run on different cpus/sockets.
Quoted 5 lines
Right. With TCP I think we are better off handling TX and RX for a socket by the same vhost, so that packet and its ack are handled by the same thread. Is this what happens with RX multiqueue patch? How do we select an RX queue to put the packet on?
My (unsubmitted) RX patch doesn't do this yet, that is something I will check.
Quoted 6 lines
Quoted 3 lines
Thanks,
- KK
You'll want to work on top of net-next, I think there's RX flow filtering work going on there.
Thanks Michael, I will follow up on that for the RX patch, plus your suggestion on tying RX with TX.
Thanks,
- KK
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): OF8043B2B7.7048D739-ON65257799.0021A2EE-65257799.00356B3E@LocalDomain
Krishna Kumar2/India/IBM wrote on 09/09/2010 03:15:53 PM:
Quoted 4 lines
I will start a full test run of original vs submitted code with minimal tuning (Avi also suggested the same), and re-send. Please let me know if you need any other data.
Same patch, only change is that I ran "taskset -p 03 <all vhost threads>", no other tuning on host or guest. Default netperf without any options. The BW is the sum across two iterations, each is 60secs. Guest is started with 2 txqs.
BW1/BW2: BW for org & new in mbps
SD1/SD2: SD for org & new
RSD1/RSD2: Remote SD for org & new
_______________________________________________________________________________
# BW1 BW2 (%) SD1 SD2 (%) RSD1 RSD2 (%)
_______________________________________________________________________________
1 20903 19422 (-7.08) 1 1 (0) 6 7
(16.66)
2 21963 24330 (10.77) 6 6 (0) 25 25 (0) 4 22042 31841 (44.45) 23 28 (21.73) 102 110 (7.84) 8 21674 32045 (47.84) 97 111 (14.43) 419 421 (.47) 16 22281 31361 (40.75) 379 551 (45.38) 1663 2110 (26.87) 24 22521 31945 (41.84) 857 981 (14.46) 3748 3742 (-.16) 32 22976 32473 (41.33) 1528 1806 (18.19) 6594 6885 (4.41) 40 23197 32594 (40.50) 2390 2755 (15.27) 10239 10450 (2.06) 48 22973 32757 (42.58) 3542 3786 (6.88) 15074 14395
(-4.50)
64 23809 32814 (37.82) 6486 6981 (7.63) 27244 26381
(-3.16)
80 23564 32682 (38.69) 10169 11133 (9.47) 43118 41397
(-3.99)
96 22977 33069 (43.92) 14954 15881 (6.19) 62948 59071
(-6.15)
128 23649 33032 (39.67) 27067 28832 (6.52) 113892 106096
(-6.84)
_______________________________________________________________________________
294534 400371 (35.9) 67504 72858 (7.9) 285077 271096
(-4.9)
_______________________________________________________________________________
I will try more tuning later as Avi suggested, wanted to test the minimal for now.
Thanks,
- KK
Michael S. Tsirkin
maintainerQuoted 1 line · Krishna Kumar
1. mq RX patch is also complete - plan to submit once TX is OK.
It's good that you split patches, I think it would be interesting to see the RX patches at least once to complete the picture.
You could make it a separate patchset, tag them as RFC.
Signature · 1 line
MST
Hi Michael,
"Michael S. Tsirkin" <[email protected]> wrote on 09/08/2010 01:43:26 PM:
Quoted 6 lines · Krishna Kumar
Quoted 1 line
1. mq RX patch is also complete - plan to submit once TX is OK.
It's good that you split patches, I think it would be interesting to see the RX patches at least once to complete the picture.
You could make it a separate patchset, tag them as RFC.
OK, I need to re-do some parts of it, since I started the TX only branch a couple of weeks earlier and the RX side is outdated. I will try to send that out in the next couple of days, as you say it will help to complete the picture. Reasons to send it only TX now:
- Reduce size of patch and complexity
- I didn't get much improvement on multiple RX patch (netperf from host -> guest), so needed some time to figure out the reason and fix it.
Thanks,
- KK