vhost: net: switch to use data copy if pending DMAs exceed the limit
Subsystems (5)
PATCH v2 1/1 vhost: net: switch to use data copy if pending DMAs exceed the limit
We used to stop the handling of tx when the number of pending DMAs exceeds VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:
+-----+ +-----+
| VM1 | | VM2 |
+--+--+ +--+--+
| |
+--+--+ +--+--+
| tap0| | tap1|
+--+--+ +--+--+
| |
pfifo_fast htb(10Mbit/s)
| |
+--+--------------+---+
| bridge |
+--+------------------+
|
pfifo_fast
|
+-----+
| eth0|(100Mbit/s)
+-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.
This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.
We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.
So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%
After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%
Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
---
Changes from V1:
- Remove VHOST_MAX_PEND and switch to use half of the vq size as the limit
- Add cpu utilization in commit log
--- drivers/vhost/net.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/vhost/net.c +7 -12
@@ -38,8 +38,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"* Using this limit prevents one virtqueue from starving others. */ #define VHOST_NET_WEIGHT 0x80000 -/* MAX number of TX used buffers for outstanding zerocopy */ -#define VHOST_MAX_PEND 128#define VHOST_GOODCOPY_LEN 256/*
@@ -345,7 +343,7 @@ static void handle_tx(struct vhost_net *net) .msg_flags = MSG_DONTWAIT, };size_t len, total_len =0 ; -int err; +int err, num_pends;size_t hdr_size;struct socket *sock;struct vhost_net_ubuf_ref *uninitialized_var (ubufs );
@@ -366,13 +364,6 @@ static void handle_tx(struct vhost_net *net)if (zcopy)vhost_zerocopy_signal_used (net, vq); -/* If more outstanding DMAs, queue the work. -* Handle upend_idx wrap around -*/ -if (unlikely ((nvq->upend_idx + vq->num -VHOST_MAX_PEND ) - %UIO_MAXIOV == nvq->done_idx)) -break ; - head = vhost_get_vq_desc(&net->dev, vq, vq->iov, ARRAY_SIZE(vq->iov), &out, &in,
@@ -405,9 +396,13 @@ static void handle_tx(struct vhost_net *net)break ; } + num_pends =likely (nvq->upend_idx >= nvq->done_idx) ? + (nvq->upend_idx - nvq->done_idx) : + (nvq->upend_idx +UIO_MAXIOV - + nvq->done_idx); + zcopy_used = zcopy && len >=VHOST_GOODCOPY_LEN - && (nvq->upend_idx +1 ) %UIO_MAXIOV != - nvq->done_idx + && num_pends <= vq->num >>1 &&vhost_net_tx_select_zcopy (net);/* use msg_control to pass vhost zerocopy ubuf info to skb */
Signature · 1 line
1.8.3.2
David Miller
maintainerFrom: Jason Wang <[email protected]>
Date: Fri, 7 Mar 2014 13:28:27 +0800
Quoted 5 lines
This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.
Isn't this essentially head of line blocking?
Quoted 26 lines
We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>
I'd like some vhost experts reviewing this before I apply it.
Quoted 123 lines · Jason Wang
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>---
Changes from V1:
- RemoveVHOST_MAX_PENDand switch to use half of the vq size as the limit
- Add cpu utilization in commit log--- drivers/vhost/net.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/vhost/net.c +3
-10@@ -38,8 +38,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"* Using this limit prevents one virtqueue from starving others. */ #define VHOST_NET_WEIGHT 0x80000 -/* MAX number of TX used buffers for outstanding zerocopy */ -#define VHOST_MAX_PEND 128#define VHOST_GOODCOPY_LEN 256/* @@ -345,7 +343,7 @@ static void handle_tx(struct vhost_net *net) .msg_flags = MSG_DONTWAIT, };size_t len, total_len =0 ; -int err; +int err, num_pends;size_t hdr_size;struct socket *sock;struct vhost_net_ubuf_ref *uninitialized_var (ubufs );@@ -366,13 +364,6 @@ static void handle_tx(struct vhost_net *net)if (zcopy)vhost_zerocopy_signal_used (net, vq); -/* If more outstanding DMAs, queue the work. -* Handle upend_idx wrap around -*/ -if (unlikely ((nvq->upend_idx + vq->num -VHOST_MAX_PEND ) - %UIO_MAXIOV == nvq->done_idx)) -break ; - head = vhost_get_vq_desc(&net->dev, vq, vq->iov, ARRAY_SIZE(vq->iov), &out, &in,@@ -405,9 +396,13 @@ static void handle_tx(struct vhost_net *net)break ; } + num_pends =likely (nvq->upend_idx >= nvq->done_idx) ? + (nvq->upend_idx - nvq->done_idx) :
drivers/vhost/net.c static void handle_tx(struct vhost_net *net) · line 408
Quoted 10 lines
drivers/vhost/net.c +4
-2+ (nvq->upend_idx +UIO_MAXIOV - + nvq->done_idx); + zcopy_used = zcopy && len >=VHOST_GOODCOPY_LEN - && (nvq->upend_idx +1 ) %UIO_MAXIOV != - nvq->done_idx + && num_pends <= vq->num >>1 &&vhost_net_tx_select_zcopy (net);/* use msg_control to pass vhost zerocopy ubuf info to skb */
Quoted 9 lines · David Miller
From: Jason Wang <[email protected]>
Date: Fri, 7 Mar 2014 13:28:27 +0800Quoted 5 lines
This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.Isn't this essentially head of line blocking?
Yes it is.
Quoted 26 lines
Quoted 26 lines
We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 7 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>I'd like some vhost experts reviewing this before I apply it.
Sure.
Michael S. Tsirkin
maintainerQuoted 66 lines · Jason Wang
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how about head_of_line_blocking with default off? This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.
Quoted 62 lines
---
Changes from V1:
- RemoveVHOST_MAX_PENDand switch to use half of the vq size as the limit
- Add cpu utilization in commit log--- drivers/vhost/net.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/vhost/net.c +7
-12@@ -38,8 +38,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"* Using this limit prevents one virtqueue from starving others. */ #define VHOST_NET_WEIGHT 0x80000 -/* MAX number of TX used buffers for outstanding zerocopy */ -#define VHOST_MAX_PEND 128#define VHOST_GOODCOPY_LEN 256/* @@ -345,7 +343,7 @@ static void handle_tx(struct vhost_net *net) .msg_flags = MSG_DONTWAIT, };size_t len, total_len =0 ; -int err; +int err, num_pends;size_t hdr_size;struct socket *sock;struct vhost_net_ubuf_ref *uninitialized_var (ubufs );@@ -366,13 +364,6 @@ static void handle_tx(struct vhost_net *net)if (zcopy)vhost_zerocopy_signal_used (net, vq); -/* If more outstanding DMAs, queue the work. -* Handle upend_idx wrap around -*/ -if (unlikely ((nvq->upend_idx + vq->num -VHOST_MAX_PEND ) - %UIO_MAXIOV == nvq->done_idx)) -break ; - head = vhost_get_vq_desc(&net->dev, vq, vq->iov, ARRAY_SIZE(vq->iov), &out, &in,@@ -405,9 +396,13 @@ static void handle_tx(struct vhost_net *net)break ; } + num_pends =likely (nvq->upend_idx >= nvq->done_idx) ? + (nvq->upend_idx - nvq->done_idx) : + (nvq->upend_idx +UIO_MAXIOV - + nvq->done_idx); + zcopy_used = zcopy && len >=VHOST_GOODCOPY_LEN - && (nvq->upend_idx +1 ) %UIO_MAXIOV != - nvq->done_idx + && num_pends <= vq->num >>1 &&vhost_net_tx_select_zcopy (net);/* use msg_control to pass vhost zerocopy ubuf info to skb */ Signature · 1 line
1.8.3.2
Michael S. Tsirkin
maintainerQuoted 66 lines · Jason Wang
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how about head_of_line_blocking with default off? This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.
Quoted 62 lines
---
Changes from V1:
- RemoveVHOST_MAX_PENDand switch to use half of the vq size as the limit
- Add cpu utilization in commit log--- drivers/vhost/net.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/vhost/net.c +7
-12@@ -38,8 +38,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"* Using this limit prevents one virtqueue from starving others. */ #define VHOST_NET_WEIGHT 0x80000 -/* MAX number of TX used buffers for outstanding zerocopy */ -#define VHOST_MAX_PEND 128#define VHOST_GOODCOPY_LEN 256/* @@ -345,7 +343,7 @@ static void handle_tx(struct vhost_net *net) .msg_flags = MSG_DONTWAIT, };size_t len, total_len =0 ; -int err; +int err, num_pends;size_t hdr_size;struct socket *sock;struct vhost_net_ubuf_ref *uninitialized_var (ubufs );@@ -366,13 +364,6 @@ static void handle_tx(struct vhost_net *net)if (zcopy)vhost_zerocopy_signal_used (net, vq); -/* If more outstanding DMAs, queue the work. -* Handle upend_idx wrap around -*/ -if (unlikely ((nvq->upend_idx + vq->num -VHOST_MAX_PEND ) - %UIO_MAXIOV == nvq->done_idx)) -break ; - head = vhost_get_vq_desc(&net->dev, vq, vq->iov, ARRAY_SIZE(vq->iov), &out, &in,@@ -405,9 +396,13 @@ static void handle_tx(struct vhost_net *net)break ; } + num_pends =likely (nvq->upend_idx >= nvq->done_idx) ? + (nvq->upend_idx - nvq->done_idx) : + (nvq->upend_idx +UIO_MAXIOV - + nvq->done_idx); + zcopy_used = zcopy && len >=VHOST_GOODCOPY_LEN - && (nvq->upend_idx +1 ) %UIO_MAXIOV != - nvq->done_idx + && num_pends <= vq->num >>1 &&vhost_net_tx_select_zcopy (net);/* use msg_control to pass vhost zerocopy ubuf info to skb */ Signature · 1 line
1.8.3.2
Quoted 73 lines · Michael S. Tsirkin
Quoted 66 lines · Jason Wang
Quoted 66 lines
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>
Quoted 10 lines
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.
Yes.
Quoted 5 lines
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how abouthead_of_line_blockingwith default off?
Sure. But the head of line blocking was only partially solved in the patch since we only support in-order completion of zerocopy packets. Maybe we need consider switching to out of order completion even for zerocopy skbs?
Quoted 10 lines
This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.
Yes, I post a RFC about 2 years ago, see
https://lkml.org/lkml/2012/4/9/478 which only traces generic vhost behaviours. I can refresh this and add some -net specific tracepoints.
Quoted 86 lines · Jason Wang
Quoted 73 lines · Michael S. Tsirkin
Quoted 66 lines · Jason Wang
Quoted 66 lines
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>Quoted 10 lines
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.Yes.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how abouthead_of_line_blockingwith default off?Sure. But the head of line blocking was only partially solved in the patch since we only support in-order completion of zerocopy packets. Maybe we need consider switching to out of order completion even for zerocopy skbs?
Yan, Dima,
I remember that there is an issue with out-of-order packets and WHQL.
Ronen.
Quoted 17 lines
Quoted 10 lines
This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.Yes, I post a RFC about 2 years ago, see
https://lkml.org/lkml/2012/4/9/478 which only traces generic vhost behaviours. I can refresh this and add some -net specific tracepoints. --
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
Quoted 90 lines · Ronen Hod
Quoted 89 lines · Jason Wang
Quoted 73 lines · Michael S. Tsirkin
Quoted 66 lines · Jason Wang
Quoted 66 lines
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>Quoted 10 lines
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.Yes.
Quoted 4 lines
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how abouthead_of_line_blockingwith default off?
Quoted 8 lines
Quoted 4 lines
Sure. But the head of line blocking was only partially solved in the patch since we only support in-order completion of zerocopy packets. Maybe we need consider switching to out of order completion even for zerocopy skbs?
Yan, Dima,
I remember that there is an issue with out-of-order packets and WHQL.
The test considers out of order packets reception as a failure.
Yan.
Quoted 21 lines
Ronen.
Quoted 10 lines
Quoted 10 lines
This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.Quoted 7 lines
Yes, I post a RFC about 2 years ago, see
https://lkml.org/lkml/2012/4/9/478 which only traces generic vhost behaviours. I can refresh this and add some -net specific tracepoints. --
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
Quoted 4 lines
--
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
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 90 lines · Ronen Hod
Quoted 89 lines · Jason Wang
Quoted 73 lines · Michael S. Tsirkin
Quoted 66 lines · Jason Wang
Quoted 66 lines
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>Quoted 10 lines
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.Yes.
Quoted 4 lines
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how abouthead_of_line_blockingwith default off?
Quoted 8 lines
Quoted 4 lines
Sure. But the head of line blocking was only partially solved in the patch since we only support in-order completion of zerocopy packets. Maybe we need consider switching to out of order completion even for zerocopy skbs?
Yan, Dima,
I remember that there is an issue with out-of-order packets and WHQL.
The test considers out of order packets reception as a failure.
Yan.
Quoted 25 lines
Ronen.
Quoted 10 lines
Quoted 10 lines
This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.Quoted 7 lines
Yes, I post a RFC about 2 years ago, see
https://lkml.org/lkml/2012/4/9/478 which only traces generic vhost behaviours. I can refresh this and add some -net specific tracepoints. --
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--
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 90 lines · Ronen Hod
Quoted 89 lines · Jason Wang
Quoted 73 lines · Michael S. Tsirkin
Quoted 66 lines · Jason Wang
Quoted 66 lines
We used to stop the handling of tx when the number of pending DMAs exceeds
VHOST_MAX_PEND. This is used to reduce the memory occupation of both host and guest. But it was too aggressive in some cases, since any delay or blocking of a single packet may delay or block the guest transmission. Consider the following setup:+-----+ +-----+ | VM1 | | VM2 | +--+--+ +--+--+ | | +--+--+ +--+--+ | tap0| | tap1| +--+--+ +--+--+ | | pfifo_fast htb(10Mbit/s) | | +--+--------------+---+ | bridge | +--+------------------+ | pfifo_fast | +-----+ | eth0|(100Mbit/s) +-----+- start two VMs and connect them to a bridge
- add an physical card (100Mbit/s) to that bridge
- setup htb on tap1 and limit its throughput to 10Mbit/s
- run two netperfs in the same time, one is from VM1 to VM2. Another is from VM1 to an external host through eth0.
- result shows that not only the VM1 to VM2 traffic were throttled but also the VM1 to external host through eth0 is also throttled somehow.This is because the delay added by htb may lead the delay the finish of DMAs and cause the pending DMAs for tap0 exceeds the limit (
VHOST_MAX_PEND). In this case vhost stop handling tx request until htb send some packets. The problem here is all of the packets transmission were blocked even if it does not go to VM2.We can solve this issue by relaxing it a little bit: switching to use data copy instead of stopping tx when the number of pending DMAs exceed half of the vq size. This is safe because:
- The number of pending DMAs were still limited (half of the vq size)
- The out of order completion during mode switch can make sure that most of the tx buffers were freed in time in guest.So even if about 50% packets were delayed in zero-copy case, vhost could continue to do the transmission through data copy in this case.
Test result:
Before this patch:
VM1 to VM2 throughput is 9.3Mbit/s
VM1 to External throughput is 40Mbit/s
CPU utilization is 7%After this patch:
VM1 to VM2 throughput is 9.3Mbit/s
Vm1 to External throughput is 93Mbit/s
CPU utilization is 16%Completed performance test on 40gbe shows no obvious changes in both throughput and cpu utilization with this patch.
Quoted 6 lines
Quoted 6 lines
The patch only solve this issue when unlimited sndbuf. We still need a solution for limited sndbuf.
Cc Michael S. Tsirkin <[email protected]>Cc Qin Chuanyu <[email protected]>Signed-off-by Jason Wang <[email protected]>Quoted 10 lines
I thought hard about this.
Here's what worries me: if there are still head of line blocking issues lurking in the stack, they will still hurt guests such as windows which rely on timely completion of buffers, but it makes it
that much harder to reproduce the problems with linux guests which don't.
And this will make even it harder to figure out whether zero copy is actually active to diagnose high cpu utilization cases.Yes.
Quoted 4 lines
So I think this is a good trick, but let's make this path conditional on a new debugging module parameter:
how abouthead_of_line_blockingwith default off?
Quoted 8 lines
Quoted 4 lines
Sure. But the head of line blocking was only partially solved in the patch since we only support in-order completion of zerocopy packets. Maybe we need consider switching to out of order completion even for zerocopy skbs?
Yan, Dima,
I remember that there is an issue with out-of-order packets and WHQL.
The test considers out of order packets reception as a failure.
Yan.
Quoted 25 lines
Ronen.
Quoted 10 lines
Quoted 10 lines
This way if we suspect packets are delayed forever somewhere, we can enable that and see guest networking block.
Additionally, I think we should add a way to count zero copy and non zero copy packets.
I see two ways to implement this: add tracepoints in vhost-net or add counters in tun accessible with ethtool.
This can be a patch on top and does not have to block this one though.Quoted 7 lines
Yes, I post a RFC about 2 years ago, see
https://lkml.org/lkml/2012/4/9/478 which only traces generic vhost behaviours. I can refresh this and add some -net specific tracepoints. --
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--
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