KVM virtio_net performance
Subsystems (3)
cover KVM virtio_net performance
Hey,
Here's a bunch of patches attempting to improve the performance
of virtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.
I've tried hard to test each of these patches with as stable and
informative a benchmark as I could find. The first benchmark is a netperf[1] based throughput benchmark and the second uses a flood ping[2] to measure latency differences.
Each set of figures is min/average/max/standard deviation. The
first set is Gb/s and the second is milliseconds.
The network configuration used was very simple - the guest with
a virtio_net interface and the host with a tap interface and static IP addresses assigned to both - e.g. there was no bridge in the host involved and iptables was disable in both the host and guest.
I used:
1) kvm-71-26-g6152996 with the patches that follow
2) Linus's v2.6.26-5752-g93ded9b with Rusty's virtio patches from 219:bbd2611289c5 applied; these are the patches have just been submitted to Linus
The conclusions I draw are:
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
2) Using the recently merged GSO support in the tun/tap driver gives
a huge boost, but much more so on the host->guest side.
3) Adjusting the virtio_net ring sizes makes a small difference, but not as much as one might expect
4) Dropping the global mutex while reading GSO packets from the tap interface gives a nice speedup. This highlights the global mutex as a general perfomance issue.
5) Eliminating an extra copy on the host->guest path only makes a barely measurable difference.
Anyway, the figures:
netperf, 10x20s runs (Gb/s) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
baseline | 1.520/ 1.573/ 1.610/ 0.034 | 1.160/ 1.357/ 1.630/ 0.165 50us tx timer + rearm | 1.050/ 1.086/ 1.110/ 0.017 | 1.710/ 1.832/ 1.960/ 0.092 250us tx timer + rearm | 1.700/ 1.764/ 1.880/ 0.064 | 0.900/ 1.203/ 1.580/ 0.205 150us tx timer + rearm | 1.520/ 1.602/ 1.690/ 0.044 | 1.670/ 1.928/ 2.150/ 0.141 no ring-full heuristic | 1.480/ 1.569/ 1.710/ 0.066 | 1.610/ 1.857/ 2.140/ 0.153 VIRTIO_F_NOTIFY_ON_EMPTY | 1.470/ 1.554/ 1.650/ 0.054 | 1.770/ 1.960/ 2.170/ 0.119 recv NO_NOTIFY | 1.530/ 1.604/ 1.680/ 0.047 | 1.780/ 1.944/ 2.190/ 0.129 GSO | 4.120/ 4.323/ 4.420/ 0.099 | 6.540/ 7.033/ 7.340/ 0.244 ring size == 256 | 4.050/ 4.406/ 4.560/ 0.143 | 6.280/ 7.236/ 8.280/ 0.613 ring size == 512 | 4.420/ 4.600/ 4.960/ 0.140 | 6.470/ 7.205/ 7.510/ 0.314 drop mutex during tapfd read | 4.320/ 4.578/ 4.790/ 0.161 | 8.370/ 8.589/ 8.730/ 0.120 aligouri zero-copy | 4.510/ 4.694/ 4.960/ 0.148 | 8.430/ 8.614/ 8.840/ 0.142
ping -f -c 100000 (ms) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
baseline | 0.060/ 0.459/ 7.602/ 0.846 | 0.067/ 0.331/ 2.517/ 0.057 50us tx timer + rearm | 0.081/ 0.143/ 7.436/ 0.374 | 0.093/ 0.133/ 1.883/ 0.026 250us tx timer + rearm | 0.302/ 0.463/ 7.580/ 0.849 | 0.297/ 0.344/ 2.128/ 0.028 150us tx timer + rearm | 0.197/ 0.323/ 7.671/ 0.740 | 0.199/ 0.245/ 7.836/ 0.037 no ring-full heuristic | 0.182/ 0.324/ 7.688/ 0.753 | 0.199/ 0.243/ 2.197/ 0.030 VIRTIO_F_NOTIFY_ON_EMPTY | 0.197/ 0.321/ 7.447/ 0.730 | 0.196/ 0.242/ 2.218/ 0.032 recv NO_NOTIFY | 0.186/ 0.321/ 7.520/ 0.732 | 0.200/ 0.233/ 2.216/ 0.028 GSO | 0.178/ 0.324/ 7.667/ 0.736 | 0.147/ 0.246/ 1.361/ 0.024 ring size == 256 | 0.184/ 0.323/ 7.674/ 0.728 | 0.199/ 0.243/ 2.181/ 0.028 ring size == 512 | (not measured) | (not measured) drop mutex during tapfd read | 0.183/ 0.323/ 7.820/ 0.733 | 0.202/ 0.242/ 2.219/ 0.027 aligouri zero-copy | 0.185/ 0.325/ 7.863/ 0.736 | 0.202/ 0.245/ 7.844/ 0.036
Cheers,
Mark.
[1] - I used netperf trunk from:
http://www.netperf.org/svn/netperf2/trunk
and simply ran:
$> i=0; while [ $i -lt 10 ]; do ./netperf -H <host> -f g -l 20 -P 0 | netperf-collect.py; i=$((i+1)); done
where netperf-collect.py is just a script to calculate the average across the runs:
http://markmc.fedorapeople.org/netperf-collect.py
[2] - ping -c 100000 -f <host>
PATCH 1/9 kvm: qemu: Set MIN_TIMER_REARM_US to 150us
Equivalent to ~300 syscalls on my machine
--- qemu/vl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
qemu/vl.c +1 -1
@@ -891,7 +891,7 @@ static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) }/* TODO: MIN_TIMER_REARM_US should be optimized */ -#define MIN_TIMER_REARM_US 250 +#define MIN_TIMER_REARM_US 150static struct qemu_alarm_timer *alarm_timer;
Signature · 1 line
1.5.4.1
PATCH 2/9 kvm: qemu: Fix virtio_net tx timer
The current virtio_net tx timer is 2ns, which doesn't make any sense. Set it to a more reasonable 150us instead.
--- qemu/hw/virtio-net.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
qemu/hw/virtio-net.c +1 -1
@@ -26,7 +26,7 @@#define VIRTIO_NET_F_MAC 5#define VIRTIO_NET_F_GS0 6 -#define TX_TIMER_INTERVAL (1000 / 500) +#define TX_TIMER_INTERVAL (150000)/* 150 us */ /* The config defining mac address (6 bytes) */ struct virtio_net_config
Signature · 1 line
1.5.4.1
PATCH 3/9 kvm: qemu: Remove virtio_net tx ring-full heuristic
virtio_net tries to guess when it has received a tx notification from the guest whether it indicates that the guest has no more room in the tx ring and it should immediately flush the queued buffers.
The heuristic is based on the fact that there are 128 buffer entries in the ring and each packet uses 2 buffers (i.e. the virtio_net_hdr and the packet's linear data).
Using GSO or increasing the size of the rings will break that heuristic, so let's remove it and assume that any notification from the guest after we've disabled notifications indicates that we should flush our buffers.
--- qemu/hw/virtio-net.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
qemu/hw/virtio-net.c +1 -2
@@ -175,8 +175,7 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) {VirtIONet *n =to_virtio_net (vdev); -if (n->tx_timer_active && - (vq->vring.avail->idx - vq->last_avail_idx) ==64 ) { +if (n->tx_timer_active) { vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;qemu_del_timer (n->tx_timer); n->tx_timer_active =0 ;
Signature · 1 line
1.5.4.1
PATCH 4/9 kvm: qemu: Add VIRTIO_F_NOTIFY_ON_EMPTY
Set the VIRTIO_F_NOTIFY_ON_EMPTY feature bit so the guest can rely on us notifying them when the queue is empty.
Also, only notify when the available queue is empty *and* when we've finished with all the buffers we had detached. Right now, when the queue is empty, we notify the guest for every used buffer.
--- qemu/hw/virtio.c | 6 +++++- qemu/hw/virtio.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletions(-)
qemu/hw/virtio.c +5 -1
@@ -138,6 +138,7 @@ void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,/* Make sure buffer is written before we update index. */ wmb (); vq->vring.used->idx++; + vq->inuse--; }int virtqueue_pop (VirtQueue *vq,VirtQueueElement *elem)
@@ -187,6 +188,8 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) elem->index = head; + vq->inuse++; +return elem->in_num + elem->out_num; }
@@ -275,6 +278,7 @@ static uint32_t virtio_ioport_read(void *opaque, uint32_t addr)switch (addr) {case VIRTIO_PCI_HOST_FEATURES : ret = vdev->get_features (vdev); + ret |= (1 <<VIRTIO_F_NOTIFY_ON_EMPTY );break ;case VIRTIO_PCI_GUEST_FEATURES : ret = vdev->features;
@@ -431,7 +435,7 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,void virtio_notify (VirtIODevice *vdev,VirtQueue *vq) {/* Always notify when queue is empty */ -if (vq->vring.avail->idx != vq->last_avail_idx && +if ((vq->inuse || vq->vring.avail->idx != vq->last_avail_idx) && (vq->vring.avail->flags &VRING_AVAIL_F_NO_INTERRUPT ))return ;
qemu/hw/virtio.h +5 -0
@@ -30,6 +30,10 @@/* We've given up on this device. */ #define VIRTIO_CONFIG_S_FAILED 0x80 +/* We notify when the ring is completely used, even if the guest is supressing +* callbacks */ +#define VIRTIO_F_NOTIFY_ON_EMPTY 24 +/* from Linux's linux/virtio_ring.h */ /* This marks a buffer as continuing via the next field. */
@@ -86,6 +90,7 @@ struct VirtQueueVRing vring;uint32_t pfn;uint16_t last_avail_idx; +int inuse;void (*handle_output)(VirtIODevice *vdev,VirtQueue *vq); };
Signature · 1 line
1.5.4.1
PATCH 5/9 kvm: qemu: Disable recv notifications until avail buffers exhausted
--- qemu/hw/virtio-net.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
qemu/hw/virtio-net.c +4 -1
@@ -106,9 +106,12 @@ static int virtio_net_can_receive(void *opaque) !(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK))return 0 ; -if (n->rx_vq->vring.avail->idx == n->rx_vq->last_avail_idx) +if (n->rx_vq->vring.avail->idx == n->rx_vq->last_avail_idx) { + n->rx_vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;return 0 ; + } + n->rx_vq->vring.used->flags |=VRING_USED_F_NO_NOTIFY ;return 1 ; }
Signature · 1 line
1.5.4.1
PATCH 6/9 kvm: qemu: Add support for partial csums and GSO
--- qemu/hw/virtio-net.c | 86 +++++++++++++++++++++++++++++++++++++++++--------- qemu/net.h | 5 +++ qemu/vl.c | 73 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 144 insertions(+), 20 deletions(-)
qemu/hw/virtio-net.c +71 -15
@@ -22,9 +22,18 @@#define VIRTIO_ID_NET 1/* The feature bitmap for virtio net */ -#define VIRTIO_NET_F_NO_CSUM 0 -#define VIRTIO_NET_F_MAC 5 -#define VIRTIO_NET_F_GS0 6 +#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 */ +#define VIRTIO_NET_F_MAC 5/* Host has given MAC address. */ +#define VIRTIO_NET_F_GSO 6/* Host handles pkts w/ any GSO type */ +#define VIRTIO_NET_F_GUEST_TSO4 7/* Guest can handle TSOv4 in. */ +#define VIRTIO_NET_F_GUEST_TSO6 8/* Guest can handle TSOv6 in. */ +#define VIRTIO_NET_F_GUEST_ECN 9/* Guest can handle TSO[6] w/ ECN in. */ +#define VIRTIO_NET_F_GUEST_UFO 10/* Guest can handle UFO in. */ +#define VIRTIO_NET_F_HOST_TSO4 11/* Host can handle TSOv4 in. */ +#define VIRTIO_NET_F_HOST_TSO6 12/* Host can handle TSOv6 in. */ +#define VIRTIO_NET_F_HOST_ECN 13/* Host can handle TSO[6] w/ ECN in. */ +#define VIRTIO_NET_F_HOST_UFO 14/* Host can handle UFO in. */ #define TX_TIMER_INTERVAL (150000)/* 150 us */
@@ -42,8 +51,6 @@ struct virtio_net_hdruint8_t flags;#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO) -/* FIXME: Do we need this? If they said they can handle ECN, do they care? */ -#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set
@@ -85,7 +92,38 @@ static void virtio_net_update_config(VirtIODevice *vdev, uint8_t *config)static uint32_t virtio_net_get_features (VirtIODevice *vdev) { -return (1 <<VIRTIO_NET_F_MAC ); +VirtIONet *n =to_virtio_net (vdev); +VLANClientState *host = n->vc->vlan->first_client; +uint32_t features = (1 <<VIRTIO_NET_F_MAC ); + +if (tap_has_offload (host)) { + features |= (1 <<VIRTIO_NET_F_CSUM ); + features |= (1 <<VIRTIO_NET_F_GUEST_CSUM ); + features |= (1 <<VIRTIO_NET_F_GUEST_TSO4 ); + features |= (1 <<VIRTIO_NET_F_GUEST_TSO6 ); + features |= (1 <<VIRTIO_NET_F_GUEST_ECN ); + features |= (1 <<VIRTIO_NET_F_HOST_TSO4 ); + features |= (1 <<VIRTIO_NET_F_HOST_TSO6 ); + features |= (1 <<VIRTIO_NET_F_HOST_ECN ); +/* Kernel can't actually handle UFO in software currently. */ + } + +return features; +} + +static void virtio_net_set_features (VirtIODevice *vdev,uint32_t features) +{ +VirtIONet *n =to_virtio_net (vdev); +VLANClientState *host = n->vc->vlan->first_client; + +if (!tap_has_offload (host) || !host->set_offload) +return ; + + host->set_offload (host, + (features >>VIRTIO_NET_F_GUEST_CSUM ) &1 , + (features >>VIRTIO_NET_F_GUEST_TSO4 ) &1 , + (features >>VIRTIO_NET_F_GUEST_TSO6 ) &1 , + (features >>VIRTIO_NET_F_GUEST_ECN ) &1 ); }/* RX */
@@ -121,6 +159,7 @@ static void virtio_net_receive(void *opaque, const uint8_t *buf, int size)VirtQueueElement elem;struct virtio_net_hdr *hdr;int offset, i; +int total;if (virtqueue_pop (n->rx_vq, &elem) ==0 )return ;
@@ -134,18 +173,26 @@ static void virtio_net_receive(void *opaque, const uint8_t *buf, int size) hdr->flags =0 ; hdr->gso_type =VIRTIO_NET_HDR_GSO_NONE ; -/* copy in packet. ugh */ offset =0 ; + total =sizeof (*hdr); + +if (tap_has_offload (n->vc->vlan->first_client)) { +memcpy (hdr, buf,sizeof (*hdr)); + offset += total; + } + +/* copy in packet. ugh */ i =1 ;while (offset < size && i < elem.in_num) {int len =MIN (elem.in_sg[i].iov_len, size - offset);memcpy (elem.in_sg[i].iov_base, buf + offset, len); offset += len; + total += len; i++; }/* signal other side */ -virtqueue_push (n->rx_vq, &elem,sizeof (*hdr) + offset); +virtqueue_push (n->rx_vq, &elem, total);virtio_notify (&n->vdev, n->rx_vq); }
@@ -153,23 +200,31 @@ static void virtio_net_receive(void *opaque, const uint8_t *buf, int size)static void virtio_net_flush_tx (VirtIONet *n,VirtQueue *vq) {VirtQueueElement elem; +int has_offload =tap_has_offload (n->vc->vlan->first_client);if (!(n->vdev.status &VIRTIO_CONFIG_S_DRIVER_OK ))return ;while (virtqueue_pop (vq, &elem)) {ssize_t len =0 ; +unsigned int out_num = elem.out_num; +struct iovec *out_sg = &elem.out_sg[0 ]; + +if (out_num <1 || out_sg->iov_len !=sizeof (struct virtio_net_hdr )) { +fprintf (stderr,"virtio-net header not in first element\n" ); +exit (1 ); + } -if (elem.out_num <1 || - elem.out_sg[0 ].iov_len !=sizeof (struct virtio_net_hdr )) { -fprintf (stderr,"virtio-net header not in first element\n" ); -exit (1 ); +/* ignore the header if GSO is not supported */ +if (!has_offload) { + out_num--; + out_sg++; + len +=sizeof (struct virtio_net_hdr ); } -/* ignore the header for now */ - len =qemu_sendv_packet (n->vc, &elem.out_sg[1 ], elem.out_num -1 ); + len +=qemu_sendv_packet (n->vc, out_sg, out_num); -virtqueue_push (vq, &elem,sizeof (struct virtio_net_hdr ) + len); +virtqueue_push (vq, &elem, len);virtio_notify (&n->vdev, vq); } }
@@ -249,6 +304,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->vdev.update_config = virtio_net_update_config; n->vdev.get_features = virtio_net_get_features; + n->vdev.set_features = virtio_net_set_features; n->rx_vq =virtio_add_queue (&n->vdev,128 , virtio_net_handle_rx); n->tx_vq =virtio_add_queue (&n->vdev,128 , virtio_net_handle_tx);memcpy (n->mac, nd->macaddr,6 );
qemu/net.h +5 -0
@@ -9,12 +9,15 @@ typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);typedef struct VLANClientState VLANClientState ; +typedef void (SetOffload )(VLANClientState *,int ,int ,int ,int ); +struct VLANClientState {IOReadHandler *fd_read;IOReadvHandler *fd_readv;/* Packets may still be sent if this returns zero. It's used to rate-limit the slirp code. */ IOCanRWHandler *fd_can_read; +SetOffload *set_offload;void *opaque;struct VLANClientState *next;struct VLANState *vlan;
@@ -42,6 +45,8 @@ void qemu_handler_true(void *opaque);void do_info_network (void ); +int tap_has_offload (void *opaque); +int net_client_init (const char *str);void net_client_uninit (NICInfo *nd);
qemu/vl.c +68 -5
143 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 7/9 kvm: qemu: Increase size of virtio_net rings
--- qemu/hw/virtio-net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
qemu/hw/virtio-net.c +2 -2
@@ -305,8 +305,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->vdev.update_config = virtio_net_update_config; n->vdev.get_features = virtio_net_get_features; n->vdev.set_features = virtio_net_set_features; - n->rx_vq =virtio_add_queue (&n->vdev,128 , virtio_net_handle_rx); - n->tx_vq =virtio_add_queue (&n->vdev,128 , virtio_net_handle_tx); + n->rx_vq =virtio_add_queue (&n->vdev,512 , virtio_net_handle_rx); + n->tx_vq =virtio_add_queue (&n->vdev,512 , virtio_net_handle_tx);memcpy (n->mac, nd->macaddr,6 ); n->vc =qemu_new_vlan_client (nd->vlan, virtio_net_receive, virtio_net_can_receive, n);
Signature · 1 line
1.5.4.1
PATCH 8/9 kvm: qemu: Drop the mutex while reading from tapfd
The idea here is that with GSO, packets are much larger and we can allow the vcpu threads to e.g. process irq acks during the window where we're reading these packets from the tapfd.
--- qemu/vl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
qemu/vl.c +2 -0
@@ -4281,7 +4281,9 @@ static void tap_send(void *opaque) sbuf.buf = s->buf; s->size =getmsg (s->fd,NULL , &sbuf, &f) >=0 ? sbuf.len :-1 ;#else +kvm_sleep_begin (); s->size =read (s->fd, s->buf,sizeof (s->buf)); +kvm_sleep_end ();#endif if (s->size ==-1 && errno ==EINTR )
Signature · 1 line
1.5.4.1
PATCH 9/9 kvm: qemu: Eliminate extra virtio_net copy
This is Anthony's net-tap-zero-copy.patch which eliminates a copy on the host->guest data path with virtio_net.
--- qemu/hw/virtio-net.c | 76 ++++++++++++++++++++++++++++++++++++------------- qemu/net.h | 3 ++ qemu/vl.c | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 20 deletions(-)
qemu/hw/virtio-net.c +56 -20
@@ -70,6 +70,8 @@ typedef struct VirtIONetVLANClientState *vc;QEMUTimer *tx_timer;int tx_timer_active; +int last_elem_valid; +VirtQueueElement last_elem; } VirtIONet;/* TODO
@@ -153,47 +155,80 @@ static int virtio_net_can_receive(void *opaque)return 1 ; } -static void virtio_net_receive (void *opaque,const uint8_t *buf,int size) +static void virtio_net_receive_zc (void *opaque,IOZeroCopyHandler *zc,void *data) {VirtIONet *n = opaque; -VirtQueueElement elem; +VirtQueueElement *elem = &n->last_elem;struct virtio_net_hdr *hdr; -int offset, i; -int total; +ssize_t err; +int idx; -if (virtqueue_pop (n->rx_vq, &elem) ==0 ) +if (!n->last_elem_valid &&virtqueue_pop (n->rx_vq, elem) ==0 )return ; -if (elem.in_num <1 || elem.in_sg[0 ].iov_len !=sizeof (*hdr)) { +if (elem->in_num <1 || elem->in_sg[0 ].iov_len !=sizeof (*hdr)) {fprintf (stderr,"virtio-net header not in first element\n" );exit (1 ); } - hdr = (void *)elem.in_sg[0 ].iov_base; + n->last_elem_valid =1 ; + + hdr = (void *)elem->in_sg[0 ].iov_base; hdr->flags =0 ; hdr->gso_type =VIRTIO_NET_HDR_GSO_NONE ; - offset =0 ; - total =sizeof (*hdr); + idx =tap_has_offload (n->vc->vlan->first_client) ?0 :1 ; + +do { + err =zc (data, &elem->in_sg[idx], elem->in_num - idx); + }while (err ==-1 && errno ==EINTR ); + +if (err ==-1 && errno ==EAGAIN ) +return ; -if (tap_has_offload (n->vc->vlan->first_client)) { -memcpy (hdr, buf,sizeof (*hdr)); - offset += total; +if (err <0 ) { +fprintf (stderr,"virtio_net: error during IO\n" ); +return ; } +/* signal other side */ + n->last_elem_valid =0 ; +virtqueue_push (n->rx_vq, elem,sizeof (*hdr) + err); +virtio_notify (&n->vdev, n->rx_vq); +} + +struct compat_data +{ +const uint8_t *buf; +int size; +}; + +static ssize_t compat_copy (void *opaque,struct iovec *iov,int iovcnt) +{ +struct compat_data *compat = opaque; +int offset, i; +/* copy in packet. ugh */ - i =1 ; -while (offset < size && i < elem.in_num) { -int len =MIN (elem.in_sg[i].iov_len, size - offset); -memcpy (elem.in_sg[i].iov_base, buf + offset, len); + offset =0 ; + i =0 ; +while (offset < compat->size && i < iovcnt) { +int len =MIN (iov[i].iov_len, compat->size - offset); +memcpy (iov[i].iov_base, compat->buf + offset, len); offset += len; - total += len; i++; } -/* signal other side */ -virtqueue_push (n->rx_vq, &elem, total); -virtio_notify (&n->vdev, n->rx_vq); +return offset; +} + +static void virtio_net_receive (void *opaque,const uint8_t *buf,int size) +{ +struct compat_data compat; + + compat.buf = buf; + compat.size = size; + +virtio_net_receive_zc (opaque, compat_copy, &compat); }/* TX */
@@ -310,6 +345,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)memcpy (n->mac, nd->macaddr,6 ); n->vc =qemu_new_vlan_client (nd->vlan, virtio_net_receive, virtio_net_can_receive, n); + n->vc->fd_read_zc = virtio_net_receive_zc; n->tx_timer =qemu_new_timer (vm_clock, virtio_net_tx_timer, n); n->tx_timer_active =0 ;
qemu/net.h +3 -0
@@ -6,6 +6,8 @@/* VLANs support */ typedef ssize_t (IOReadvHandler )(void *,const struct iovec *,int ); +typedef ssize_t (IOZeroCopyHandler )(void *,struct iovec *,int ); +typedef void (IOReadZCHandler )(void *,IOZeroCopyHandler *,void *);typedef struct VLANClientState VLANClientState ;
@@ -14,6 +16,7 @@ typedef void (SetOffload)(VLANClientState *, int, int, int, int);struct VLANClientState {IOReadHandler *fd_read;IOReadvHandler *fd_readv; +IOReadZCHandler *fd_read_zc;/* Packets may still be sent if this returns zero. It's used to rate-limit the slirp code. */ IOCanRWHandler *fd_can_read;
qemu/vl.c +50 -0
68 lines not on this page · raw message
Signature · 1 line
1.5.4.1
Re: [PATCH 8/9] kvm: qemu: Drop the mutex while reading from tapfd
In reply to Mark McLoughlinQuoted 15 lines · Mark McLoughlin
The idea here is that with GSO, packets are much larger and we can allow the vcpu threads to e.g. process irq acks during the window where we're reading these packets from the tapfd.
Signed-off-by Mark McLoughlin <[email protected]>--- qemu/vl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)qemu/vl.c +0
-0
qemu/vl.c static void tap_send(void *opaque) · line 4284
Quoted 4 lines
qemu/vl.c +0
-0@@ -4281,7 +4281,9 @@ static void tap_send(void *opaque) sbuf.buf = s->buf; s->size =getmsg (s->fd,NULL , &sbuf, &f) >=0 ? sbuf.len :-1 ;#else
Maybe do it only when GSO is actually used by the guest/tap. Otherwise it can cause some ctx trashing right?
Quoted 7 lines
qemu/vl.c +2
-0+kvm_sleep_begin (); s->size =read (s->fd, s->buf,sizeof (s->buf)); +kvm_sleep_end ();#endif if (
s->size== -1 && errno == EINTR)
Re: [PATCH 8/9] kvm: qemu: Drop the mutex while reading from tapfd
Quoted 6 lines · Dor Laor
Quoted 5 lines · Mark McLoughlin
The idea here is that with GSO, packets are much larger and we can allow the vcpu threads to e.g. process irq acks during the window where we're reading these packets from the tapfd.
...
Quoted 11 lines
qemu/vl.c static void tap_send(void *opaque) · line 4284
Quoted 9 lines
qemu/vl.c +0
-0@@ -4281,7 +4281,9 @@ static void tap_send(void *opaque) sbuf.buf = s->buf; s->size =getmsg (s->fd,NULL , &sbuf, &f) >=0 ? sbuf.len :-1 ;#else Maybe do it only when GSO is actually used by the guest/tap. Otherwise it can cause some ctx trashing right?
(Strange habit you have of "top commenting" on patches :-)
I've been meaning to do some profiling of just how long the vcpu thread spends blocking on the mutex in this case, both before and after the GSO patches.
i.e. this change may make sense even with smaller buffers ...
Quoted 3 lines
qemu/vl.c static void tap_send(void *opaque) · line 4286
Quoted 3 lines
qemu/vl.c +2
-0+kvm_sleep_begin (); s->size =read (s->fd, s->buf,sizeof (s->buf)); +kvm_sleep_end ();
Cheers,
Mark.
Re: [PATCH 3/9] kvm: qemu: Remove virtio_net tx ring-full heuristic
In reply to Mark McLoughlinQuoted 24 lines · Mark McLoughlin
virtio_nettries to guess when it has received a tx notification from the guest whether it indicates that the guest has no more room in the tx ring and it should immediately flush the queued buffers.The heuristic is based on the fact that there are 128 buffer entries in the ring and each packet uses 2 buffers (i.e. the
virtio_net_hdrand the packet's linear data).Using GSO or increasing the size of the rings will break that heuristic, so let's remove it and assume that any notification from the guest after we've disabled notifications indicates that we should flush our buffers.
Signed-off-by Mark McLoughlin <[email protected]>--- qemu/hw/virtio-net.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)qemu/hw/virtio-net.c +0
-0
qemu/hw/virtio-net.c static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) · line 179
Quoted 7 lines
qemu/hw/virtio-net.c +1
-2@@ -175,8 +175,7 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) {VirtIONet *n =to_virtio_net (vdev); -if (n->tx_timer_active && - (vq->vring.avail->idx - vq->last_avail_idx) ==64 ) { +if (n->tx_timer_active) {
Actually it was worthless anyway since if we set the timer, the flag below would have been cleared, causing the guest not to notify the host, thus the ==64 never called.
So I'm in favour too.
Quoted 4 lines
qemu/hw/virtio-net.c +0
-0vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;qemu_del_timer (n->tx_timer);
n->tx_timer_active= 0;
As stated by newer messages, we should handle the first tx notification if the timer wasn't active to shorten latency. Cheers, Dor
Re: [PATCH 3/9] kvm: qemu: Remove virtio_net tx ring-full heuristic
Quoted 8 lines · On Friday 25 July 2008 09:22:53 Dor Laor wrote:
qemu/hw/virtio-net.c static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) · line 181
Quoted 3 lines · Mark McLoughlin
qemu/hw/virtio-net.c +0
-0vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;qemu_del_timer (n->tx_timer); n->tx_timer_active =0 ;As stated by newer messages, we should handle the first tx notification if the timer wasn't active to shorten latency.
Cheers, Dor
Here's what lguest does at the moment. Basically, we cut the timeout a tiny bit each time, until we get *fewer* packets than last time. Then we bump it up again.
Rough, but seems to work (it should be a per-device var of course, not a static).
@@ -921,6 +922,7 @@ static void handle_net_output(int fd, st
unsigned int head, out, in, num = 0;
int len;
struct iovec iov[vq->vring.num];
+ static int last_timeout_num;
if (!timeout)
net_xmit_notify++;
@@ -941,6 +943,14 @@ static void handle_net_output(int fd, st
/* Block further kicks and set up a timer if we saw anything. */ if (!timeout && num)
block_vq(vq);
+
+ if (timeout) {
+ if (num < last_timeout_num)
+ timeout_usec += 10;
+ else if (timeout_usec > 1)
+ timeout_usec--;
+ last_timeout_num = num;
+ }
}
Re: [PATCH 3/9] kvm: qemu: Remove virtio_net tx ring-full heuristic
Quoted 27 lines · Rusty Russell
Quoted 8 lines · On Friday 25 July 2008 09:22:53 Dor Laor wrote:
qemu/hw/virtio-net.c static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) · line 181
Quoted 3 lines · Mark McLoughlin
qemu/hw/virtio-net.c +0
-0vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;qemu_del_timer (n->tx_timer); n->tx_timer_active =0 ;As stated by newer messages, we should handle the first tx notification if the timer wasn't active to shorten latency.
Cheers, DorHere's what lguest does at the moment. Basically, we cut the timeout a tiny bit each time, until we get *fewer* packets than last time. Then we bump it up again.
Rough, but seems to work (it should be a per-device var of course, not a static).
(quoted diff) +1
-0@@ -921,6 +922,7 @@ static void handle_net_output(int fd, st unsigned int head, out, in, num = 0; int len; struct iovec iov[vq->vring.num]; + static int last_timeout_num; if (!timeout) net_xmit_notify++;@@ -941,6 +943,14 @@ static void handle_net_output(int fd, st /* Block further kicks and set up a timer if we saw anything. */
Review static void handle_net_output(int fd, st · line 953
Quoted 10 lines
(quoted diff) +8
-0if (!timeout && num) block_vq(vq); + + if (timeout) { + if (num < last_timeout_num) + timeout_usec += 10; + else if (timeout_usec > 1) + timeout_usec--; + last_timeout_num = num; + }
Yeah, I gave this a try in kvm and in the host->guest case the timeout just grew and grew. In the guest->host case, it did stabilise at around 50us with high throughput.
Basically, I think in the host->guest case the number of buffers was very variable so the timeout would get bumped by 10, reduced by a small amount, bumped by 10, reduced by a small amount, ...
But, I agree the general principal seems about right; just needs some tweaking.
Cheers,
Mark.
Re: [PATCH 3/9] kvm: qemu: Remove virtio_net tx ring-full heuristic
In reply to Dor LaorQuoted 5 lines · Dor Laor
Quoted 4 lines · Mark McLoughlin
virtio_nettries to guess when it has received a tx notification from the guest whether it indicates that the guest has no more room in the tx ring and it should immediately flush the queued buffers.
...
Quoted 7 lines
qemu/hw/virtio-net.c static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) · line 178
Quoted 4 lines
qemu/hw/virtio-net.c +1
-2-if (n->tx_timer_active && - (vq->vring.avail->idx - vq->last_avail_idx) ==64 ) { +if (n->tx_timer_active) {Actually it was worthless anyway since if we set the timer, the flag below would have been cleared,
causing the guest not to notify the host, thus the ==64 never called.
No, that's the point I'm trying to make in the commit message - the guest ignores the NO_NOTIFY flag when the tx queue fills up and sends a notification anyway.
The "== 64" test seems to be an attempt to catch this ring-full condition.
Well, actually the test was worthless for a different reason, I guess. If tx_timer_active is set and we get a notification, then given the current guest code the number of buffers available should *always* be 64.
Cheers,
Mark.
Re: [PATCH 3/9] kvm: qemu: Remove virtio_net tx ring-full heuristic
In reply to Mark McLoughlinQuoted 25 lines · Mark McLoughlin
virtio_nettries to guess when it has received a tx notification from the guest whether it indicates that the guest has no more room in the tx ring and it should immediately flush the queued buffers.The heuristic is based on the fact that there are 128 buffer entries in the ring and each packet uses 2 buffers (i.e. the
virtio_net_hdrand the packet's linear data).Using GSO or increasing the size of the rings will break that heuristic, so let's remove it and assume that any notification from the guest after we've disabled notifications indicates that we should flush our buffers.
Signed-off-by Mark McLoughlin <[email protected]>--- qemu/hw/virtio-net.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)qemu/hw/virtio-net.c +0
-0
qemu/hw/virtio-net.c static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) · line 181
Quoted 9 lines
qemu/hw/virtio-net.c +1
-2@@ -175,8 +175,7 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) {VirtIONet *n =to_virtio_net (vdev); -if (n->tx_timer_active && - (vq->vring.avail->idx - vq->last_avail_idx) ==64 ) { +if (n->tx_timer_active) { vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY ;qemu_del_timer (n->tx_timer); n->tx_timer_active =0 ;
Actually we can improve latency a bit more by using this timer only for high throughput scenario. For example, if during the previous timer period no/few packets were accumulated, we can set the flag off and not issue new timer. This way we'll get notified immediately without timer latency. When lots of packets will be transmitted, we'll go back to this batch mode again. Cheers, Dor
Re: [PATCH 2/9] kvm: qemu: Fix virtio_net tx timer
In reply to Mark McLoughlinQuoted 14 lines · Mark McLoughlin
The current
virtio_nettx timer is 2ns, which doesn't make any sense. Set it to a more reasonable 150us instead.Signed-off-by Mark McLoughlin <[email protected]>--- qemu/hw/virtio-net.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)qemu/hw/virtio-net.c +0
-0
qemu/hw/virtio-net.c line 31
Quoted 7 lines
qemu/hw/virtio-net.c +1
-1@@ -26,7 +26,7 @@#define VIRTIO_NET_F_MAC 5#define VIRTIO_NET_F_GS0 6 -#define TX_TIMER_INTERVAL (1000 / 500) +#define TX_TIMER_INTERVAL (150000)/* 150 us */
Ouch.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Re: [PATCH 2/9] kvm: qemu: Fix virtio_net tx timer
Quoted 18 lines · Avi Kivity
Quoted 17 lines · Mark McLoughlin
The current
virtio_nettx timer is 2ns, which doesn't make any sense. Set it to a more reasonable 150us instead.Signed-off-by Mark McLoughlin <[email protected]>--- qemu/hw/virtio-net.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)qemu/hw/virtio-net.c +0
-0@@ -26,7 +26,7 @@#define VIRTIO_NET_F_MAC 5#define VIRTIO_NET_F_GS0 6
Quoted 5 lines
qemu/hw/virtio-net.c line 30
Quoted 3 lines
qemu/hw/virtio-net.c +1
-1-#define TX_TIMER_INTERVAL (1000 / 500) +#define TX_TIMER_INTERVAL (150000)/* 150 us */ Ouch.
Well, not so much - and I should have explained why.
Even though virtio-net is requesting a 2ns tx timer, it actually gets limited to MIN_TIMER_REARM_US which is currently 250us.
However, even though the timer itself will only fire after 250us, expire_time is only set to +2ns, so we'll get the timeout callback next time qemu_run_timers() is called from the mainloop.
I think this might account for a lot of the jitter in the throughput numbers - the effective tx window size is anywhere between 2ns and 250us depending on e.g. whether there is rx data available on the tap fd.
Cheers,
Mark.
Quoted 4 lines · Mark McLoughlin
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.
Nice patches Mark, your work is always of the highest calibre!
Quoted 2 lines
2) Using the recently merged GSO support in the tun/tap driver gives
a huge boost, but much more so on the host->guest side.
IIRC the reason guest=>host isn't so good is because the tuntap GSO interface isn't the best when it comes to getting data from user-space.
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHey,
One all all-important thing I forgot to include was a comparison with
lguest :-)
netperf, 10x20s runs (Gb/s) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
KVM | 4.230/ 4.619/ 4.780/ 0.155 | 8.140/ 8.578/ 8.770/ 0.162 lguest | 5.700/ 5.926/ 6.150/ 0.132 | 8.680/ 9.073/ 9.320/ 0.205
ping -f -c 100000 (ms) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
KVM | 0.199/ 0.326/ 7.698/ 0.744 | 0.199/ 0.245/ 0.402/ 0.022 lguest | 0.022/ 0.055/ 0.467/ 0.019 | 0.019/ 0.046/89.249/ 0.448
So, puppies gets you an extra 1.3Gb/s guest->host, .5Gb/s host->guest
and much better latency.
Actually, I guess the main reason for the latency difference is that
when lguest gets notified on the tx ring, it immediately sends whatever is available and then starts a timer. KVM doesn't send anything until it's tx timer fires or the ring is full.
Cheers,
Mark.
Quoted 4 lines · Mark McLoughlin
Hey,
One all all-important thing I forgot to include was a comparison with
lguest :-)
Hey Mark,
This patch set is really great! I guess the hard part now is deciding what all we want to apply. Do you have a suggestion of which patches you think are worth applying?
BTW, do you have native and guest loopback numbers to compare where we stand with native?
Quoted 5 lines
netperf, 10x20s runs (Gb/s) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------KVM | 4.230/ 4.619/ 4.780/ 0.155 | 8.140/ 8.578/ 8.770/ 0.162 lguest | 5.700/ 5.926/ 6.150/ 0.132 | 8.680/ 9.073/ 9.320/ 0.205
Quoted 9 lines
ping -f -c 100000 (ms) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------KVM | 0.199/ 0.326/ 7.698/ 0.744 | 0.199/ 0.245/ 0.402/ 0.022 lguest | 0.022/ 0.055/ 0.467/ 0.019 | 0.019/ 0.046/89.249/ 0.448So, puppies gets you an extra 1.3Gb/s guest->host, .5Gb/s host->guestand much better latency.
I'm surprised lguest gets an extra 1.3gb guest->host. Any idea of where we're loosing it?
Quoted 5 lines
Actually, I guess the main reason for the latency difference is that
when lguest gets notified on the tx ring, it immediately sends whatever is available and then starts a timer. KVM doesn't send anything until it's tx timer fires or the ring is full.
Yes, we should definitely do that. It will make ping appear to be a lot faster than it really is :-)
Regards,
Anthony Liguori
Quoted 8 lines
Cheers,
Mark.--
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
Quoted 11 lines · Anthony Liguori
Quoted 4 lines · Mark McLoughlin
Hey,
One all all-important thing I forgot to include was a comparison with
lguest :-)Hey Mark,
This patch set is really great! I guess the hard part now is deciding what all we want to apply. Do you have a suggestion of which patches you think are worth applying?
Good question. I think they're all fairly sane as a starting point, I guess.
Making the tx timer adaptive, dropping the mutex when writing to the tap interface and flushing the tx queue immediately on notify are all things worth adding too, but they could be an additional patch set.
Your zero-copy patch is quite a chunk for not much gain - how do you feel about that? Could we get that in upstream qemu?
Quoted 2 lines
BTW, do you have native and guest loopback numbers to compare where we stand with native?
Yep, sorry:
netperf, 10x20s runs (Gb/s) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
KVM | 4.230/ 4.619/ 4.780/ 0.155 | 8.140/ 8.578/ 8.770/ 0.162 lguest | 5.700/ 5.926/ 6.150/ 0.132 | 8.680/ 9.073/ 9.320/ 0.205 loopback | 9.520/12.473/15.390/ 1.947
ping -f -c 100000 (ms) | guest->host | host->guest
-----------------------------+----------------------------+---------------------------
KVM | 0.199/ 0.326/ 7.698/ 0.744 | 0.199/ 0.245/ 0.402/ 0.022 lguest | 0.022/ 0.055/ 0.467/ 0.019 | 0.019/ 0.046/89.249/ 0.448 loopback | 0.001/ 0.002/ 0.025/ 0.001
Very surprising how much jitter there is in the loopback throughput figures.
Quoted 2 lines
I'm surprised lguest gets an extra 1.3gb
guest->host. Any idea of where we're loosing it?
The main difference on the tx path would appear to be the adaptive timeout and the immediate flushing of the queue on notify.
Cheers,
Mark.
Hi Mark,
Quoted 6 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.
I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
Configuring the tap device with a static address, here's what I get with iperf:
w/o patches:
guest->host: 625 Mbits/sechost->guest: 825 Mbits/sec
w/patches
guest->host: 2.02 Gbits/sechost->guest: 1.89 Gbits/sec
guest lo: 4.35 Gbits/sec
host lo: 4.36 Gbits/sec
This is with KVM GUEST configured FWIW.
Regards,
Anthony Liguori
Quoted 94 lines
I've tried hard to test each of these patches with as stable and
informative a benchmark as I could find. The first benchmark is a netperf[1] based throughput benchmark and the second uses a flood ping[2] to measure latency differences.Each set of figures is min/average/max/standard deviation. The
first set is Gb/s and the second is milliseconds.The network configuration used was very simple - the guest with
avirtio_netinterface and the host with a tap interface and static IP addresses assigned to both - e.g. there was no bridge in the host involved and iptables was disable in both the host and guest.I used:
1) kvm-71-26-g6152996 with the patches that follow
2) Linus's v2.6.26-5752-g93ded9b with Rusty's virtio patches from 219:bbd2611289c5 applied; these are the patches have just been submitted to Linus
The conclusions I draw are:
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
2) Using the recently merged GSO support in the tun/tap driver gives
a huge boost, but much more so on the host->guest side.3) Adjusting the
virtio_netring sizes makes a small difference, but not as much as one might expect4) Dropping the global mutex while reading GSO packets from the tap interface gives a nice speedup. This highlights the global mutex as a general perfomance issue.
5) Eliminating an extra copy on the
host->guestpath only makes a barely measurable difference.Anyway, the figures:
netperf, 10x20s runs (Gb/s) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------baseline | 1.520/ 1.573/ 1.610/ 0.034 | 1.160/ 1.357/ 1.630/ 0.165 50us tx timer + rearm | 1.050/ 1.086/ 1.110/ 0.017 | 1.710/ 1.832/ 1.960/ 0.092 250us tx timer + rearm | 1.700/ 1.764/ 1.880/ 0.064 | 0.900/ 1.203/ 1.580/ 0.205 150us tx timer + rearm | 1.520/ 1.602/ 1.690/ 0.044 | 1.670/ 1.928/ 2.150/ 0.141 no ring-full heuristic | 1.480/ 1.569/ 1.710/ 0.066 | 1.610/ 1.857/ 2.140/ 0.153 VIRTIO_F_NOTIFY_ON_EMPTY | 1.470/ 1.554/ 1.650/ 0.054 | 1.770/ 1.960/ 2.170/ 0.119 recv NO_NOTIFY | 1.530/ 1.604/ 1.680/ 0.047 | 1.780/ 1.944/ 2.190/ 0.129 GSO | 4.120/ 4.323/ 4.420/ 0.099 | 6.540/ 7.033/ 7.340/ 0.244 ring size == 256 | 4.050/ 4.406/ 4.560/ 0.143 | 6.280/ 7.236/ 8.280/ 0.613 ring size == 512 | 4.420/ 4.600/ 4.960/ 0.140 | 6.470/ 7.205/ 7.510/ 0.314 drop mutex during tapfd read | 4.320/ 4.578/ 4.790/ 0.161 | 8.370/ 8.589/ 8.730/ 0.120 aligouri zero-copy | 4.510/ 4.694/ 4.960/ 0.148 | 8.430/ 8.614/ 8.840/ 0.142ping -f -c 100000 (ms) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------baseline | 0.060/ 0.459/ 7.602/ 0.846 | 0.067/ 0.331/ 2.517/ 0.057 50us tx timer + rearm | 0.081/ 0.143/ 7.436/ 0.374 | 0.093/ 0.133/ 1.883/ 0.026 250us tx timer + rearm | 0.302/ 0.463/ 7.580/ 0.849 | 0.297/ 0.344/ 2.128/ 0.028 150us tx timer + rearm | 0.197/ 0.323/ 7.671/ 0.740 | 0.199/ 0.245/ 7.836/ 0.037 no ring-full heuristic | 0.182/ 0.324/ 7.688/ 0.753 | 0.199/ 0.243/ 2.197/ 0.030 VIRTIO_F_NOTIFY_ON_EMPTY | 0.197/ 0.321/ 7.447/ 0.730 | 0.196/ 0.242/ 2.218/ 0.032 recv NO_NOTIFY | 0.186/ 0.321/ 7.520/ 0.732 | 0.200/ 0.233/ 2.216/ 0.028 GSO | 0.178/ 0.324/ 7.667/ 0.736 | 0.147/ 0.246/ 1.361/ 0.024 ring size == 256 | 0.184/ 0.323/ 7.674/ 0.728 | 0.199/ 0.243/ 2.181/ 0.028 ring size == 512 | (not measured) | (not measured) drop mutex during tapfd read | 0.183/ 0.323/ 7.820/ 0.733 | 0.202/ 0.242/ 2.219/ 0.027 aligouri zero-copy | 0.185/ 0.325/ 7.863/ 0.736 | 0.202/ 0.245/ 7.844/ 0.036Cheers,
Mark.[1] - I used netperf trunk from:
http://www.netperf.org/svn/netperf2/trunk
and simply ran:
$> i=0; while [ $i -lt 10 ]; do ./netperf -H <host> -f g -l 20 -P 0 | netperf-collect.py; i=$((i+1)); donewhere
netperf-collect.pyis just a script to calculate the average across the runs:http://markmc.fedorapeople.org/netperf-collect.py
[2] - ping -c 100000 -f <host>
--
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
Quoted 10 lines · Anthony Liguori
Hi Mark,
Quoted 6 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.
Quoted 4 lines
I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
I've just tried bridging to my physical LAN and DHCP seems to be working fine.
Which reminds me, though - doing this makes host->guest throughput drop to well below pre-GSO figures. GSO appears to be disabled while there's a physical interface on the bridge. If I remove eth0, the figures jump right back up again.
I also just noticed that the GSO patch breaks e1000 because it unconditionally sets IFF_VNET_HDR. Will fix that up.
Quoted 8 lines
Configuring the tap device with a static address, here's what I get with iperf:
w/o patches:
guest->host: 625 Mbits/sechost->guest: 825 Mbits/sec
Quoted 7 lines
w/patches
guest->host: 2.02 Gbits/sechost->guest: 1.89 Gbits/secguest lo: 4.35 Gbits/sec
host lo: 4.36 Gbits/sec
I tried iperf at one point and was getting really low figures; not sure why.
Apart from your iperf figures being lower than my netperf figures, it also contradicts what I was seeing - namely guest->host beating host->guest before the patches and host->guest beating guest->host after the patches.
It could all just be down to the length of the tx timer. If you try adjusting that does it help?
Quoted 1 line
This is with KVM GUEST configured FWIW.
Yep, same here.
Cheers,
Mark.
Quoted 40 lines · Mark McLoughlin
Quoted 4 lines · Anthony Liguori
Hi Mark,
Mark McLoughlin wrote:
Quoted 9 lines
Quoted 7 lines
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
I've just tried bridging to my physical LAN and DHCP seems to be working fine.
Which reminds me, though - doing this makes
host->guestthroughput drop to well below pre-GSO figures. GSO appears to be disabled while there's a physical interface on the bridge. If I remove eth0, the figures jump right back up again.I also just noticed that the GSO patch breaks e1000 because it unconditionally sets
IFF_VNET_HDR. Will fix that up.Quoted 12 lines
Configuring the tap device with a static address, here's what I get with iperf:
w/o patches:
guest->host: 625 Mbits/sechost->guest: 825 Mbits/secw/patches
guest->host: 2.02 Gbits/sechost->guest: 1.89 Gbits/sec
Quoted 8 lines
Quoted 3 lines
guest lo: 4.35 Gbits/sec
host lo: 4.36 Gbits/secI tried iperf at one point and was getting really low figures; not sure why.
Older iperf (~2.0.2) has locking vs yield bug and consumes lots of cpu. In 2.0.4 it is fixed. Can that be the difference?
Quoted 22 lines
Apart from your iperf figures being lower than my netperf figures, it also contradicts what I was seeing - namely
guest->hostbeatinghost->guestbefore the patches andhost->guestbeatingguest->hostafter the patches.It could all just be down to the length of the tx timer. If you try adjusting that does it help?
Quoted 2 lines
This is with KVM GUEST configured FWIW.
Yep, same here.
Cheers,
Mark.--
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
Quoted 11 lines · Anthony Liguori
Hi Mark,
Quoted 6 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
I have been discussing this (on this list) in another thread. Putting tcpdump on the eth0 device in the VM, the br0 device in the host, and the eth0 (physical NIC) in the host, you can see that when the VM generates a DHCP request it shows up on the br0 in the host, but never gets sent on the wire by eth0.
That's the point of failure, at least using RHEL5/FC6/kvm-66 as the environment.
Quoted 22 lines
Configuring the tap device with a static address, here's what I get with iperf:
w/o patches:
guest->host: 625 Mbits/sechost->guest: 825 Mbits/secw/patches
guest->host: 2.02 Gbits/sechost->guest: 1.89 Gbits/secguest lo: 4.35 Gbits/sec
host lo: 4.36 Gbits/secThis is with KVM GUEST configured FWIW.
Regards,
Anthony Liguori
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 11 lines · Bill Davidsen
Quoted 10 lines · Anthony Liguori
Hi Mark,
Quoted 6 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.
Quoted 5 lines
Quoted 1 line
I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
I have been discussing this (on this list) in another thread. Putting tcpdump on the eth0 device in the VM, the br0 device in the host, and the eth0 (physical NIC) in the host, you can see that when the VM generates a DHCP request it shows up on the br0 in the host, but never gets sent on the wire by eth0.
That's the point of failure, at least using RHEL5/FC6/kvm-66 as the environment.
Does playing with the bridge forward delay ('brctl setfd') help?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
Quoted 4 lines · Bill Davidsen
Quoted 3 lines · Anthony Liguori
Hi Mark,
[...snip...]
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address. Rusty noticed that RX has a lot more packets received then it should so we're suspicious that we're getting packet corruption.
I have been discussing this (on this list) in another thread. Putting tcpdump on the eth0 device in the VM, the br0 device in the host, and the eth0 (physical NIC) in the host, you can see that when the VM generates a DHCP request it shows up on the br0 in the host, but never gets sent on the wire by eth0.
That's the point of failure, at least using RHEL5/FC6/kvm-66 as the environment.
Does playing with the bridge forward delay ('brctl setfd') help?
Not obviously, default value is 15, stepping from 10..30 made no difference. It appears the bridge just doesn't forward DHCP packets. I'm not an expert on bridge setup, and I don't see an obvious control, so I will look at the code this afternoon and see if something jumps out at me.
Signature · 3 lines
Bill Davidsen <[email protected]> "Woe unto the statesman who makes war without a reason that will still be valid when the war is over..." Otto von Bismark
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Bill Davidsen
I have been discussing this (on this list) in another thread. Putting tcpdump on the eth0 device in the VM, the br0 device in the host, and the eth0 (physical NIC) in the host, you can see that when the VM generates a DHCP request it shows up on the br0 in the host, but never gets sent on the wire by eth0.
That's the point of failure, at least using RHEL5/FC6/kvm-66 as the environment.
Does playing with the bridge forward delay ('brctl setfd') help?
Update: Redhat has a user chain in iptables shared between INPUT and FORWARD (bad idea) which doesn't pass bootp packets by default. Adding the following rules to that table solved the DHCP for me.
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc ACCEPT udp -- anywhere anywhere udp spt:bootpc dpt:bootps
This seems to solve my problem, I just have to make it part of my "start kvm" procedure.
Signature · 3 lines
Bill Davidsen <[email protected]> "Woe unto the statesman who makes war without a reason that will still be valid when the war is over..." Otto von Bismark
Quoted 9 lines · Bill Davidsen
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Bill Davidsen
I have been discussing this (on this list) in another thread. Putting tcpdump on the eth0 device in the VM, the br0 device in the host, and the eth0 (physical NIC) in the host, you can see that when the VM generates a DHCP request it shows up on the br0 in the host, but never gets sent on the wire by eth0.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
That's the point of failure, at least using RHEL5/FC6/kvm-66 as the environment.
Does playing with the bridge forward delay ('brctl setfd') help?
Update: Redhat has a user chain in iptables shared between INPUT and FORWARD (bad idea) which doesn't pass bootp packets by default.
Yeah, I've been trying to get that rule changed to allow all bridged packets to be forwarded by default. See:
https://bugzilla.redhat.com/221828
Quoted 10 lines
Adding
the following rules to that table solved the DHCP for me.ACCEPT udp -- anywhere anywhere udp
spt:bootps dpt:bootpc
ACCEPT udp -- anywhere anywhere udp
spt:bootpc dpt:bootpsThis seems to solve my problem, I just have to make it part of my "start kvm" procedure.
See here:
http://wiki.libvirt.org/page/Networking
in the 'Bridged networking (aka "shared physical device")' section:
# echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" > /etc/sysconfig/iptables-forward-bridged # lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged # service libvirtd reload
Cheers,
Mark.
Quoted 2 lines · On Friday 25 July 2008 06:56:01 you wrote:
I'm still seeing the same problem I saw with my patch series. Namely, dhclient fails to get a DHCP address.
This is, from one point of view, a dhclient bug. It opens a packet socket, and we'd tell it that the checksum is incomplete via auxdata, but it doesn't have auxdata.
On the other hand, perhaps we should copy the packet and checksum it in this case? Not many devices input packets with partial csums, so dhclient doesn't normally hit this. Xen might though?
ie, in net/packet/af_packet.c's packet_recvmsg():
if (pkt_sk(sk)->auxdata) {
struct tpacket_auxdata aux;
aux.tp_status = TP_STATUS_USER;
if (skb->ip_summed == CHECKSUM_PARTIAL)
aux.tp_status |= TP_STATUS_CSUMNOTREADY;
aux.tp_len = PACKET_SKB_CB(skb)->origlen;
aux.tp_snaplen = skb->len;
aux.tp_mac = 0;
aux.tp_net = skb_network_offset(skb);
aux.tp_vlan_tci = skb->vlan_tci;
put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
}add an "else if (skb->ip_summed == CHECKSUM_PARTIAL)" case...
Rusty.
Quoted 2 lines · Rusty Russell
add an "else if (
skb->ip_summed==CHECKSUM_PARTIAL)" case...
If you're going to hack the guest kernel, then you might as well fix the guest DHCP client. However, we should default checksum offload to off until we know that the client is capable of handling it (to handle guests that haven't been fixed).
One easy way of doing this is to hook up the rx checksum offload option in the guest with the tx offload option in the host. In other words, when rx offload is enabled in the guest we enable tx offload in the host, and disable it vice versa.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtcsum offload and af_packet
Quoted 7 lines · On Monday 11 August 2008 19:51:39 Herbert Xu wrote:
Quoted 1 line · Rusty Russell
add an "else if (
skb->ip_summed==CHECKSUM_PARTIAL)" case...If you're going to hack the guest kernel, then you might as well fix the guest DHCP client. However, we should default checksum offload to off until we know that the client is capable of handling it (to handle guests that haven't been fixed).
I think this is deeper than that. This case is actually unusual, in that the packet really does arrive with a partial csum. But usually, we're exposing an internal detail of our stack at this point. Seems like we shouldn't if we know the user can't deal with it. dhcpd just makes this case less academic.
Quoted 4 lines
One easy way of doing this is to hook up the rx checksum offload option in the guest with the tx offload option in the host. In other words, when rx offload is enabled in the guest we enable tx offload in the host, and disable it vice versa.
We can trivially disable it in the guest or host; that's not the problem. We can even disable csum offload just for UDP in the host. But should we really?
Rusty.
Re: csum offload and af_packet
Quoted 5 lines · Rusty Russell
I think this is deeper than that. This case is actually unusual, in that the packet really does arrive with a partial csum. But usually, we're exposing an internal detail of our stack at this point. Seems like we shouldn't if we know the user can't deal with it. dhcpd just makes this case less academic.
I disagree. If you're using AF_PACKET you're asking to see the bare details. If you want to see the censored version you can always go through the IP stack.
Quoted 3 lines
We can trivially disable it in the guest or host; that's not the problem. We can even disable csum offload just for UDP in the host. But should we really?
It's not about disabling it, it's about enabling it dynamically once guest user-space is sure that *it* can handle this.
Cheers,`
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerRe: csum offload and af_packet
From: Herbert Xu <[email protected]>
Date: Tue, 12 Aug 2008 08:32:44 +0800
Quoted 10 lines · Rusty Russell
Quoted 5 lines
I think this is deeper than that. This case is actually unusual, in that the packet really does arrive with a partial csum. But usually, we're exposing an internal detail of our stack at this point. Seems like we shouldn't if we know the user can't deal with it. dhcpd just makes this case less academic.
I disagree. If you're using
AF_PACKETyou're asking to see the bare details. If you want to see the censored version you can always go through the IP stack.
Unfortunately the censored version doesn't allow you to get at the link level headers, which is what at least some of these applications want.
Re: csum offload and af_packet
Quoted 4 lines · David Miller
Unfortunately the censored version doesn't allow you to get at the link level headers, which is what at least some of these applications want.
Yes that is certainly true for the DHCP server, but Rusty was complaining about the DHCP client which certainly does not need the LL headers on reception (although using it is definitely more convenient since you need it on transmit anyway).
I agree that handling this in AF_PACKET is certainly possible, and for that matter not extremely difficult. However, my point is that doing this for the purposes of virtualisation is completely pointless.
The only time you need this is when you have an old guest that you cannot modify. If you could modify it you can always give it a patched DHCP client (I've alread patched dhcp-client for Xen so that should work properly for KVM/lguest if you're using the latest version).
And if you can't modify it then patching AF_PACKET is completely pointless since we need to do this in the guest kernel and not the host kernel.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtRe: csum offload and af_packet
Quoted 5 lines · Herbert Xu
The only time you need this is when you have an old guest that you cannot modify. If you could modify it you can always give it a patched DHCP client (I've alread patched dhcp-client for Xen so that should work properly for KVM/lguest if you're using the latest version).
Are you talking about modifying the KVM client image?
There may be reasons, why this is impossible or at least highly undesired.
Before virtualisation developers of embedded stuff need to seal away their whole machines for their development and test environment together with sample hardware.
Now using virtualisation they can at least virtualize their development and test environment, save lots of cost and not risking that their sealed away hardware will not start again, when they need to fix a critical bug 10-20 years later.
Now try to have them change the KVM client image :-)
Extreme special case, not worth optimizing for, I know. But that special case is a legal one like any other special case we care about now.
Best Regards
Ingo Oeser
Re: csum offload and af_packet
Quoted 4 lines · Ingo Oeser
Are you talking about modifying the KVM client image?
There may be reasons, why this is impossible or at least highly undesired.
Quoted 8 lines
Before virtualisation developers of embedded stuff need to seal away their whole machines for their development and test environment together with sample hardware.
Now using virtualisation they can at least virtualize their development and test environment, save lots of cost and not risking that their sealed away hardware will not start again, when they need to fix a critical bug 10-20 years later.
Oh I totally agree that there are lots of scenarios where you want to have an unmolested guest image. My point was that if you're going to touch the guest kernel anyway you might as well fix the guest user-space instead.
This is also why I've argued that the default should be to disable TX checksums until the guest enables it so that old guests that know nothing about this can continue to work.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerRe: csum offload and af_packet
From: Herbert Xu <[email protected]>
Date: Wed, 13 Aug 2008 09:37:53 +1000
Quoted 8 lines
Oh I totally agree that there are lots of scenarios where you want to have an unmolested guest image. My point was that if you're going to touch the guest kernel anyway you might as well fix the guest user-space instead.
This is also why I've argued that the default should be to disable TX checksums until the guest enables it so that old guests that know nothing about this can continue to work.
However, I think Rusty may have a point.
The whole point of the auxdata thing was that if your tool is smart you can get the notification that the checksum is going to be HW computed and therefore keep capturing at a very low cost.
But for a stupid AF_PACKET user, like dhclient currently is, there is no harm in COW'ing the packet header area and calculating the checksum for them in this case.
I kind of hope that libpcap/tcpdump has been taught about auxdata by now, has it? :-/
Re: csum offload and af_packet
Quoted 8 lines · David Miller
The whole point of the auxdata thing was that if your tool is smart you can get the notification that the checksum is going to be HW computed and therefore keep capturing at a very low cost.
But for a stupid
AF_PACKETuser, like dhclient currently is, there is no harm in COW'ing the packet header area and calculating the checksum for them in this case.
Right I'm not against adding this to AF_PACKET.
It's just that the virtualisation problem that started all this is just as easily resolved by user-space. In fact the dhcp-client code in RHEL/Fedora has been patched to do exactly this a long time ago.
Quoted 2 lines
I kind of hope that libpcap/tcpdump has been taught about auxdata by now, has it? :-/
Unfortunately no. This also means that if we do do this in AF_PACKET, then running a packet dump on a fast outbound interface may become more expensive.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerRe: csum offload and af_packet
From: Herbert Xu <[email protected]>
Date: Wed, 13 Aug 2008 11:09:35 +1000
Quoted 7 lines · David Miller
Quoted 2 lines
I kind of hope that libpcap/tcpdump has been taught about auxdata by now, has it? :-/
Unfortunately no. This also means that if we do do this in
AF_PACKET, then running a packet dump on a fast outbound interface may become more expensive.
It seems pointless for us to add features like mmap() support and auxdata if the most important client library and tool users of these features never take it up.
libpcap and tcpdump have been notoriously difficult in this area.
Re: csum offload and af_packet
Quoted 4 lines · David Miller
It seems pointless for us to add features like
mmap()support and auxdata if the most important client library and tool users of these features never take it up.
Well auxdata at least is used by dhcp-common and therefore dhcp-client and dhcp-server.
Quoted 1 line
libpcap and tcpdump have been notoriously difficult in this area.
Yes the disconnect between the kernel community and the rest is large. The only successful examples seems to be where the user- space code is maintained by a kernel developer, e.g., iproute.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerRe: csum offload and af_packet
From: Herbert Xu <[email protected]>
Date: Wed, 13 Aug 2008 11:21:29 +1000
Quoted 8 lines · David Miller
Quoted 4 lines
It seems pointless for us to add features like
mmap()support and auxdata if the most important client library and tool users of these features never take it up.Well auxdata at least is used by dhcp-common and therefore dhcp-client and dhcp-server.
Only because _YOU_ added it :-)
Quoted 5 lines
Quoted 1 line
libpcap and tcpdump have been notoriously difficult in this area.
Yes the disconnect between the kernel community and the rest is large. The only successful examples seems to be where the user- space code is maintained by a kernel developer, e.g., iproute.
Isn't that the truth...
Alexey was maintaining his own semi-fork of libpcap and tcpdump for years for the same reasons.
Let's write a real packet capturing tool that will be fast and that we can add quick support for new kernel features to.
I mean, what other alternative is there? The pcap/tcpdump folks have had 10+ years to get their act in gear.
Re: csum offload and af_packet
Quoted 3 lines · David Miller
Alexey was maintaining his own semi-fork of libpcap and tcpdump for years for the same reasons.
He had a whole suite of things, some of which are now finally making it into the mainstream distros.
Quoted 5 lines
Let's write a real packet capturing tool that will be fast and that we can add quick support for new kernel features to.
I mean, what other alternative is there? The pcap/tcpdump folks have had 10+ years to get their act in gear.
Maybe we could start from Alexey's code base.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtRe: csum offload and af_packet
In reply to Herbert XuQuoted 10 lines · Herbert Xu
Quoted 3 lines · David Miller
I kind of hope that libpcap/tcpdump has been taught about auxdata by now, has it? :-/
Unfortunately no. This also means that if we do do this in
AF_PACKET, then running a packet dump on a fast outbound interface may become more expensive.
Actually the current CVS version understands auxdata and uses it to reconstruct VLAN headers. CVS seems to be broken though, I can send you a tarball with the current version if you want.
David Miller
maintainerRe: csum offload and af_packet
From: Patrick McHardy <[email protected]>
Date: Wed, 13 Aug 2008 13:26:22 +0200
Quoted 3 lines
Actually the current CVS version understands auxdata and uses it to reconstruct VLAN headers. CVS seems to be broken though, I can send you a tarball with the current version if you want.
At first I thought you were saying that the code in their current CVS is broken, but now I understand that CVS itself is broken for this project.
That's rediculious.
I'll see if I can put some time together to try and put some trees together, please send me what you have Patrick, thanks.
If I'm successful I'll put GIT trees up on kernel.org for tcpdump and libpcap which we can hack on.
Thanks guys.
Re: csum offload and af_packet
Quoted 6 lines · David Miller
I'll see if I can put some time together to try and put some trees together, please send me what you have Patrick, thanks.
If I'm successful I'll put GIT trees up on kernel.org for tcpdump and libpcap which we can hack on.
That's awesome! Thanks Dave!
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerRe: csum offload and af_packet
From: Herbert Xu <[email protected]>
Date: Mon, 18 Aug 2008 11:10:18 +1000
Quoted 9 lines · David Miller
Quoted 6 lines
I'll see if I can put some time together to try and put some trees together, please send me what you have Patrick, thanks.
If I'm successful I'll put GIT trees up on kernel.org for tcpdump and libpcap which we can hack on.
That's awesome! Thanks Dave!
There is a libpcap.git up in my dir on kernel.org:
master.kernel.org:/pub/scm/linux/kernel/git/davem/libpcap.git
It's just a bare 0.9.8 import plus a commit to get rid of all of the rcsid strings.
A message that is not in the archive (sent off-list or not yet received): [email protected]
David Miller
maintainerRe: csum offload and af_packet
From: Patrick McHardy <[email protected]>
Date: Mon, 18 Aug 2008 03:13:35 +0200
Quoted 4 lines
Actually both I guess, the current version finally has mmaped packet socket support and the linux support looks a lot cleaner in general, but I stumbled over a few bugs that indicate alpha-state. The maintainer is very responsive though.
...
Quoted 1 line
I've attached the last snapshot I have.
Thanks Patrick.
David Miller
maintainerRe: csum offload and af_packet
In reply to a message not in the archiveFrom: Patrick McHardy <[email protected]>
Date: Mon, 18 Aug 2008 03:13:35 +0200
Quoted 1 line
the linux support looks a lot cleaner in general
I totally disagree after having looked at this thing.
The number of ifdefs has doubled in pcap-linux.c since the last official release, it's quite a mess. It's still handling all sorts of obscure bugs we had back in 2.0.x as well.
Re: csum offload and af_packet
Quoted 6 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Mon, 18 Aug 2008 03:13:35 +0200Quoted 1 line
the linux support looks a lot cleaner in general
I totally disagree after having looked at this thing.
You should have seen the old mmaped packet socket support :) But I agree, it certainly could be done cleaner.
Re: csum offload and af_packet
In reply to Herbert XuQuoted 10 lines · On Tuesday 12 August 2008 10:32:44 Herbert Xu wrote:
Quoted 5 lines · Rusty Russell
I think this is deeper than that. This case is actually unusual, in that the packet really does arrive with a partial csum. But usually, we're exposing an internal detail of our stack at this point. Seems like we shouldn't if we know the user can't deal with it. dhcpd just makes this case less academic.
I disagree. If you're using
AF_PACKETyou're asking to see the bare details. If you want to see the censored version you can always go through the IP stack.
Then should we insist the user set PACKET_AUXDATA? Even then, the format of that cmsg will have to be enhanced as we change kernel internals. Which is probably why you *don't* get to see the bare details: you get a flag saying "oh, I know the checksum is bad". Without the csum_start/csum_offset fields you can't even calculate what it will be.
The dhcp client thing is a symptom which can be fixed, but are we doing the right thing? (Tho for lguest this is a new problem with the current kernel, so fixing it now means it really wouldn't be a problem).
Quoted 6 lines
Quoted 3 lines
We can trivially disable it in the guest or host; that's not the problem.
We can even disable csum offload just for UDP in the host. But should
we really?It's not about disabling it, it's about enabling it dynamically once guest user-space is sure that *it* can handle this.
Oh, I see. I'd have to think harder; I'm not sure if we have all the pieces at the moment for virtio or would need a boutique mechanism for this (usually the host doesn't change the features it offers, even if device resets). May be easier to suppress csum offload for dhcp packets in the host...
Rusty.
Quoted 27 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.I've tried hard to test each of these patches with as stable and
informative a benchmark as I could find. The first benchmark is a netperf[1] based throughput benchmark and the second uses a flood ping[2] to measure latency differences.Each set of figures is min/average/max/standard deviation. The
first set is Gb/s and the second is milliseconds.The network configuration used was very simple - the guest with
avirtio_netinterface and the host with a tap interface and static IP addresses assigned to both - e.g. there was no bridge in the host involved and iptables was disable in both the host and guest.I used:
1) kvm-71-26-g6152996 with the patches that follow
2) Linus's v2.6.26-5752-g93ded9b with Rusty's virtio patches from 219:bbd2611289c5 applied; these are the patches have just been submitted to Linus
Quoted 6 lines
The conclusions I draw are:
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
The tx mitigation timer is just one part of the equation; the other is the virtio ring window size, which is now fixed.
Using a maximum sized window is good when the guest and host are running flat out, doing nothing but networking. When throughput drops (because the guest is spending cpu on processing, or simply because the other side is not keeping up), we need to drop the windows size so as to retain acceptable latencies.
The tx timer can then be set to "a bit after the end of the window", acting as a safety belt in case the throughput changes.
Quoted 5 lines
4) Dropping the global mutex while reading GSO packets from the tap interface gives a nice speedup. This highlights the global mutex as a general perfomance issue.
Not sure whether this is safe. What's stopping the guest from accessing virtio and changing some state?
Quoted 4 lines
5) Eliminating an extra copy on the
host->guestpath only makes a barely measurable difference.
That's expected on a host->guest test. Zero copy is mostly important for guest->external, and with zerocopy already enabled in the guest (sendfile or nfs server workloads).
Quoted 4 lines
Anyway, the figures:
netperf, 10x20s runs (Gb/s) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------
Quoted 13 lines
baseline | 1.520/ 1.573/ 1.610/ 0.034 | 1.160/ 1.357/ 1.630/ 0.165 50us tx timer + rearm | 1.050/ 1.086/ 1.110/ 0.017 | 1.710/ 1.832/ 1.960/ 0.092 250us tx timer + rearm | 1.700/ 1.764/ 1.880/ 0.064 | 0.900/ 1.203/ 1.580/ 0.205 150us tx timer + rearm | 1.520/ 1.602/ 1.690/ 0.044 | 1.670/ 1.928/ 2.150/ 0.141 no ring-full heuristic | 1.480/ 1.569/ 1.710/ 0.066 | 1.610/ 1.857/ 2.140/ 0.153 VIRTIO_F_NOTIFY_ON_EMPTY | 1.470/ 1.554/ 1.650/ 0.054 | 1.770/ 1.960/ 2.170/ 0.119 recv NO_NOTIFY | 1.530/ 1.604/ 1.680/ 0.047 | 1.780/ 1.944/ 2.190/ 0.129 GSO | 4.120/ 4.323/ 4.420/ 0.099 | 6.540/ 7.033/ 7.340/ 0.244 ring size == 256 | 4.050/ 4.406/ 4.560/ 0.143 | 6.280/ 7.236/ 8.280/ 0.613 ring size == 512 | 4.420/ 4.600/ 4.960/ 0.140 | 6.470/ 7.205/ 7.510/ 0.314 drop mutex during tapfd read | 4.320/ 4.578/ 4.790/ 0.161 | 8.370/ 8.589/ 8.730/ 0.120 aligouri zero-copy | 4.510/ 4.694/ 4.960/ 0.148 | 8.430/ 8.614/ 8.840/ 0.142
Very impressive numbers; much better than I expected. The host->guest numbers are around 100x better than the original emulated card througput we got from kvm.
Quoted 16 lines
ping -f -c 100000 (ms) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------baseline | 0.060/ 0.459/ 7.602/ 0.846 | 0.067/ 0.331/ 2.517/ 0.057 50us tx timer + rearm | 0.081/ 0.143/ 7.436/ 0.374 | 0.093/ 0.133/ 1.883/ 0.026 250us tx timer + rearm | 0.302/ 0.463/ 7.580/ 0.849 | 0.297/ 0.344/ 2.128/ 0.028 150us tx timer + rearm | 0.197/ 0.323/ 7.671/ 0.740 | 0.199/ 0.245/ 7.836/ 0.037 no ring-full heuristic | 0.182/ 0.324/ 7.688/ 0.753 | 0.199/ 0.243/ 2.197/ 0.030 VIRTIO_F_NOTIFY_ON_EMPTY | 0.197/ 0.321/ 7.447/ 0.730 | 0.196/ 0.242/ 2.218/ 0.032 recv NO_NOTIFY | 0.186/ 0.321/ 7.520/ 0.732 | 0.200/ 0.233/ 2.216/ 0.028 GSO | 0.178/ 0.324/ 7.667/ 0.736 | 0.147/ 0.246/ 1.361/ 0.024 ring size == 256 | 0.184/ 0.323/ 7.674/ 0.728 | 0.199/ 0.243/ 2.181/ 0.028 ring size == 512 | (not measured) | (not measured) drop mutex during tapfd read | 0.183/ 0.323/ 7.820/ 0.733 | 0.202/ 0.242/ 2.219/ 0.027 aligouri zero-copy | 0.185/ 0.325/ 7.863/ 0.736 | 0.202/ 0.245/ 7.844/ 0.036
This isn't too good. Low latency is important for nfs clients (or other request/response workloads). I think we can keep these low by adjusting the virtio window (for example, on an idle system it should be 1), so that the tx mitigation timer only fires when the workload transitions from throughput to request/response.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 37 lines · On Saturday 26 July 2008 19:45:36 Avi Kivity wrote:
Quoted 27 lines · Mark McLoughlin
Hey,
Here's a bunch of patches attempting to improve the performance
ofvirtio_net. This is more an RFC rather than a patch submission since, as can be seen below, not all patches actually improve the perfomance measurably.I've tried hard to test each of these patches with as stable and
informative a benchmark as I could find. The first benchmark is a netperf[1] based throughput benchmark and the second uses a flood ping[2] to measure latency differences.Each set of figures is min/average/max/standard deviation. The
first set is Gb/s and the second is milliseconds.The network configuration used was very simple - the guest with
avirtio_netinterface and the host with a tap interface and static IP addresses assigned to both - e.g. there was no bridge in the host involved and iptables was disable in both the host and guest.I used:
1) kvm-71-26-g6152996 with the patches that follow
2) Linus's v2.6.26-5752-g93ded9b with Rusty's virtio patches from 219:bbd2611289c5 applied; these are the patches have just been submitted to Linus
Quoted 5 lines
The conclusions I draw are:
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
The tx mitigation timer is just one part of the equation; the other is the virtio ring window size, which is now fixed.
Quoted 8 lines
Using a maximum sized window is good when the guest and host are running flat out, doing nothing but networking. When throughput drops (because the guest is spending cpu on processing, or simply because the other side is not keeping up), we need to drop the windows size so as to retain acceptable latencies.
The tx timer can then be set to "a bit after the end of the window", acting as a safety belt in case the throughput changes.
Interestingly, I played a little with a threshold patch. Unfortunately it seemed to just add YA variable to the mix; it'd take real research to figure out how to adjust the threshold and timeout values appropriately for different situations.
Quoted 7 lines
This isn't too good. Low latency is important for nfs clients (or other request/response workloads). I think we can keep these low by adjusting the virtio window (for example, on an idle system it should be 1), so that the tx mitigation timer only fires when the workload transitions from throughput to request/response.
From reading this thread, this seems like an implementation bug. Don't
suppress notifications on an empty ring (ie. threshold will be 1 when nothing is happening).
Rusty.
Quoted 6 lines · On Saturday 26 July 2008 19:45:36 Avi Kivity wrote:
Quoted 2 lines
5) Eliminating an extra copy on the
host->guestpath only makes a barely measurable difference.That's expected on a
host->guesttest. Zero copy is mostly important forguest->external, and with zerocopy already enabled in the guest (sendfile or nfs server workloads).
Note that this will also need the copyless tun patches. If we're doing one copy from userspace->kernel anyway, this extra copy is probably lost in the noise.
Cheers,
Rusty.
Hi Avi,
Sorry, I got distracted from this ...
Quoted 10 lines · Avi Kivity
Quoted 4 lines · Mark McLoughlin
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
The tx mitigation timer is just one part of the equation; the other is the virtio ring window size, which is now fixed.
Quoted 8 lines
Using a maximum sized window is good when the guest and host are running flat out, doing nothing but networking. When throughput drops (because the guest is spending cpu on processing, or simply because the other side is not keeping up), we need to drop the windows size so as to retain acceptable latencies.
The tx timer can then be set to "a bit after the end of the window", acting as a safety belt in case the throughput changes.
i.e. the tx timer should give just enough time for a flat out guest to fill the ring, and no more?
Yep, that's basically what lguest's tx timer heuristic is aiming for AFAICT.
Quoted 8 lines
Quoted 5 lines
4) Dropping the global mutex while reading GSO packets from the tap interface gives a nice speedup. This highlights the global mutex as a general perfomance issue.
Not sure whether this is safe. What's stopping the guest from accessing virtio and changing some state?
With the current code, the virtio state should be consistent before we drop the mutex. The I/O thread would only drop the lock while it reads into the tap buffer and then grab the lock again before popping a buffer from the ring and copying to it.
With Anthony's zero-copy patch, the situation is less clear - we pop a buffer from the avail, drop the lock, read() into the buffer, grab the lock and then push the buffer back onto the used ring. While the mutex is released, the guest could e.g. reset the ring and release the buffer which we're in the process of read()ing too.
So, yes - dropping the mutex during read() in the zero-copy patch isn't safe.
Another potential concern is that if we drop the mutex, the guest thread could delete an I/O handler while the I/O thread is in the I/O handler loop in main_loop_wait(). However, this seems to have been coded to handle this situation - the I/O handler would only be marked as deleted, and ignored by the loop.
Oh, and there's the posix-timers/signalfd race condition that I can only seem to trigger when dropping the mutex.
Quoted 8 lines
Quoted 4 lines
5) Eliminating an extra copy on the
host->guestpath only makes a barely measurable difference.That's expected on a
host->guesttest. Zero copy is mostly important forguest->external, and with zerocopy already enabled in the guest (sendfile or nfs server workloads).
Hmm, could you elaborate on that?
The copy we're eliminating here is an intermediate copy from tapfd into a buffer before copying to a guest buffer. It doesn't give you zero-copy as we still copy from kernel space to user space and vice-versa.
Quoted 18 lines
Quoted 4 lines
Anyway, the figures:
netperf, 10x20s runs (Gb/s) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------Quoted 13 lines
baseline | 1.520/ 1.573/ 1.610/ 0.034 | 1.160/ 1.357/ 1.630/ 0.165 50us tx timer + rearm | 1.050/ 1.086/ 1.110/ 0.017 | 1.710/ 1.832/ 1.960/ 0.092 250us tx timer + rearm | 1.700/ 1.764/ 1.880/ 0.064 | 0.900/ 1.203/ 1.580/ 0.205 150us tx timer + rearm | 1.520/ 1.602/ 1.690/ 0.044 | 1.670/ 1.928/ 2.150/ 0.141 no ring-full heuristic | 1.480/ 1.569/ 1.710/ 0.066 | 1.610/ 1.857/ 2.140/ 0.153 VIRTIO_F_NOTIFY_ON_EMPTY | 1.470/ 1.554/ 1.650/ 0.054 | 1.770/ 1.960/ 2.170/ 0.119 recv NO_NOTIFY | 1.530/ 1.604/ 1.680/ 0.047 | 1.780/ 1.944/ 2.190/ 0.129 GSO | 4.120/ 4.323/ 4.420/ 0.099 | 6.540/ 7.033/ 7.340/ 0.244 ring size == 256 | 4.050/ 4.406/ 4.560/ 0.143 | 6.280/ 7.236/ 8.280/ 0.613 ring size == 512 | 4.420/ 4.600/ 4.960/ 0.140 | 6.470/ 7.205/ 7.510/ 0.314 drop mutex during tapfd read | 4.320/ 4.578/ 4.790/ 0.161 | 8.370/ 8.589/ 8.730/ 0.120 aligouri zero-copy | 4.510/ 4.694/ 4.960/ 0.148 | 8.430/ 8.614/ 8.840/ 0.142
Quoted 3 lines
Very impressive numbers; much better than I expected. The
host->guestnumbers are around 100x better than the original emulated card througput we got from kvm.
Hmm, I had intended to post comparison numbers for e1000; if I re-run these again, I'll do that too. I think it's about 0.5 Gb/s guest->host and 1.5 Gb/s host->guest.
Note also that with current Fedora rawhide kernels the numbers aren't nearly as good as the numbers using my own kernel builds. This could be down to the fact that we enable pretty much all kernel debugging options during this phase of Fedora development. If I get a chance, I'll see if I can confirm that suspicion.
Quoted 17 lines
Quoted 16 lines
ping -f -c 100000 (ms) |
guest->host|host->guest
-----------------------------+----------------------------+---------------------------baseline | 0.060/ 0.459/ 7.602/ 0.846 | 0.067/ 0.331/ 2.517/ 0.057 50us tx timer + rearm | 0.081/ 0.143/ 7.436/ 0.374 | 0.093/ 0.133/ 1.883/ 0.026 250us tx timer + rearm | 0.302/ 0.463/ 7.580/ 0.849 | 0.297/ 0.344/ 2.128/ 0.028 150us tx timer + rearm | 0.197/ 0.323/ 7.671/ 0.740 | 0.199/ 0.245/ 7.836/ 0.037 no ring-full heuristic | 0.182/ 0.324/ 7.688/ 0.753 | 0.199/ 0.243/ 2.197/ 0.030 VIRTIO_F_NOTIFY_ON_EMPTY | 0.197/ 0.321/ 7.447/ 0.730 | 0.196/ 0.242/ 2.218/ 0.032 recv NO_NOTIFY | 0.186/ 0.321/ 7.520/ 0.732 | 0.200/ 0.233/ 2.216/ 0.028 GSO | 0.178/ 0.324/ 7.667/ 0.736 | 0.147/ 0.246/ 1.361/ 0.024 ring size == 256 | 0.184/ 0.323/ 7.674/ 0.728 | 0.199/ 0.243/ 2.181/ 0.028 ring size == 512 | (not measured) | (not measured) drop mutex during tapfd read | 0.183/ 0.323/ 7.820/ 0.733 | 0.202/ 0.242/ 2.219/ 0.027 aligouri zero-copy | 0.185/ 0.325/ 7.863/ 0.736 | 0.202/ 0.245/ 7.844/ 0.036
Quoted 5 lines
This isn't too good. Low latency is important for nfs clients (or other request/response workloads). I think we can keep these low by adjusting the virtio window (for example, on an idle system it should be 1), so that the tx mitigation timer only fires when the workload transitions from throughput to request/response
The other suggestion to help latency is to always flush the queue immediately on guest notification, before setting the timer.
Cheers,
Mark.
Quoted 5 lines · Mark McLoughlin
Hi Avi,
Sorry, I got distracted from this ...
So did I :)
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
1) The length of the tx mitigation timer makes quite a difference to throughput achieved; we probably need a good heuristic for adjusting this on the fly.
The tx mitigation timer is just one part of the equation; the other is the virtio ring window size, which is now fixed.
Using a maximum sized window is good when the guest and host are running flat out, doing nothing but networking. When throughput drops (because the guest is spending cpu on processing, or simply because the other side is not keeping up), we need to drop the windows size so as to retain acceptable latencies.
Quoted 10 lines
Quoted 2 lines
The tx timer can then be set to "a bit after the end of the window", acting as a safety belt in case the throughput changes.
i.e. the tx timer should give just enough time for a flat out guest to fill the ring, and no more?
Yep, that's basically what lguest's tx timer heuristic is aiming for AFAICT.
Yes, but that's not enough. If networking is slow (for whatever reason) we need to drop the window size, to make sure the timer never fires under steady state circumstances.
Thinking about it, we could have an explicit "worst case latency" parameter (instead of the implicit "flat out guest fills ring") and set the timer to that. Adjust window size to as large as we can without seeing the timer expire.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
4) Dropping the global mutex while reading GSO packets from the tap interface gives a nice speedup. This highlights the global mutex as a general perfomance issue.
Quoted 9 lines
Quoted 2 lines
Not sure whether this is safe. What's stopping the guest from accessing virtio and changing some state?
With the current code, the virtio state should be consistent before we drop the mutex. The I/O thread would only drop the lock while it reads into the tap buffer and then grab the lock again before popping a buffer from the ring and copying to it.
Right, tap_send() is called outside virtio-net context.
Quoted 6 lines
With Anthony's zero-copy patch, the situation is less clear - we pop a buffer from the avail, drop the lock,
read()into the buffer, grab the lock and then push the buffer back onto the used ring. While the mutex is released, the guest could e.g. reset the ring and release the buffer which we're in the process of read()ing too.
Quoted 9 lines
So, yes - dropping the mutex during
read()in the zero-copy patch isn't safe.Another potential concern is that if we drop the mutex, the guest thread could delete an I/O handler while the I/O thread is in the I/O handler loop in
main_loop_wait(). However, this seems to have been coded to handle this situation - the I/O handler would only be marked as deleted, and ignored by the loop.
I think it's safe. Still I don't feel good about it.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
5) Eliminating an extra copy on the
host->guestpath only makes a barely measurable difference.
Quoted 9 lines
Quoted 2 lines
That's expected on a
host->guesttest. Zero copy is mostly important forguest->external, and with zerocopy already enabled in the guest (sendfile or nfs server workloads).Hmm, could you elaborate on that?
The copy we're eliminating here is an intermediate copy from tapfd into a buffer before copying to a guest buffer. It doesn't give you zero-copy as we still copy from kernel space to user space and vice-versa.
So long as we're eliminating intermediate copies, each elimination is not bring us much. It's the elimination of the last copy that brings the benefit (actually, the last copy for each separate L2 cache; need to test on loaded multisocket hosts).
There are broadly three workload categories wrt copying:
- server-side static http/nfs/smb protocols, serving to clients outside the host: guest is already copyless; serving from cache-cold buffers
- normal network servers that actually process their data: you'll have a guest kernel/user copy, and in any case, guest protocol processing means that the potential for gains from eliminating copies is limited
- guest/host benchmarks, which do a copy from a single buffer which is always in L1: zero copy is not going to show a gain (perhaps the opposite)
To get the first workload type optimized, we have to get the entire path copyless.
Signature · 1 line
error compiling committee.c: too many arguments to function