virtio-net: don't disable guest csum when disable LRO
Subsystems (4)
PATCH v2 1/1 virtio-net: don't disable guest csum when disable LRO
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
---
v2:
* change the fix-tag
--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/virtio_net.c +7 -1
@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = {VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;
@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err)
Signature · 1 line
2.23.0
Michael S. Tsirkin
maintainerQuoted 23 lines · On Tue, Sep 29, 2020 at 09:58:06AM +0800, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +0
-0
drivers/net/virtio_net.c static const unsigned long guest_offloads[] = { · line 70
Quoted 8 lines
drivers/net/virtio_net.c +5
-0@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +
I think I'd rather we open-coded this, the macro is only used in one place ...
Quoted 16 lines
drivers/net/virtio_net.c +2
-1struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err)Signature · 2 lines
-- 2.23.0
Quoted 28 lines · Michael S. Tsirkin
Quoted 26 lines · On Tue, Sep 29, 2020 at 09:58:06AM +0800, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +0
-0@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM };
Quoted 8 lines
drivers/net/virtio_net.c static const unsigned long guest_offloads[] = { · line 70
Quoted 5 lines
drivers/net/virtio_net.c +5
-0+#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +I think I'd rather we open-coded this, the macro is only used in one place ...
Yes, in this patch, it is used only in one place. But in next patch [1], we use it twice and that make the code look a bit nicer. Would we open-coded this in this patch ?
[1] - http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/
Quoted 17 lines
Quoted 16 lines
drivers/net/virtio_net.c +2
-2struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err) --2.23.0
Signature · 1 line
Best regards, Tonghao
Michael S. Tsirkin
maintainerQuoted 37 lines · Tonghao Zhang
Quoted 28 lines · Michael S. Tsirkin
Quoted 26 lines · On Tue, Sep 29, 2020 at 09:58:06AM +0800, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +0
-0@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM };Quoted 8 lines
drivers/net/virtio_net.c static const unsigned long guest_offloads[] = { · line 70
Quoted 5 lines
drivers/net/virtio_net.c +5
-0+#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +I think I'd rather we open-coded this, the macro is only used in one place ...
Quoted 5 lines
Yes, in this patch, it is used only in one place. But in next patch [1], we use it twice and that make the code look a bit nicer. Would we open-coded this in this patch ?
[1] - http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/
OK then maybe keep this in a series like you did with v1.
Quoted 21 lines
Quoted 17 lines
Quoted 16 lines
drivers/net/virtio_net.c +2
-2struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err) --2.23.0
Signature · 1 line
Best regards, Tonghao
Quoted 39 lines · Michael S. Tsirkin
Quoted 37 lines · Tonghao Zhang
Quoted 36 lines · Michael S. Tsirkin
Quoted 23 lines · On Tue, Sep 29, 2020 at 09:58:06AM +0800, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +0
-0drivers/net/virtio_net.c static const unsigned long guest_offloads[] = { · line 70
Quoted 8 lines
drivers/net/virtio_net.c +5
-0@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +I think I'd rather we open-coded this, the macro is only used in one place ...
Quoted 7 lines
Quoted 5 lines
Yes, in this patch, it is used only in one place. But in next patch [1], we use it twice and that make the code look a bit nicer. Would we open-coded this in this patch ?
[1] - http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/
OK then maybe keep this in a series like you did with v1.
If this is a fix it has to target net, unlike the other patch.
Quoted 45 lines · Willem de Bruijn
Quoted 43 lines · Michael S. Tsirkin
Quoted 41 lines · Tonghao Zhang
Quoted 28 lines · Michael S. Tsirkin
Quoted 26 lines · On Tue, Sep 29, 2020 at 09:58:06AM +0800, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +0
-0@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM };Quoted 8 lines
drivers/net/virtio_net.c static const unsigned long guest_offloads[] = { · line 70
Quoted 5 lines
drivers/net/virtio_net.c +5
-0+#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +I think I'd rather we open-coded this, the macro is only used in one place ...
Yes, in this patch, it is used only in one place. But in next patch [1], we use it twice and that make the code look a bit nicer. Would we open-coded this in this patch ?
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
[1] - http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/
OK then maybe keep this in a series like you did with v1.
If this is a fix it has to target net, unlike the other patch.
Hi Willem, Michael
The first patch v2 is for -net, can we apply it?
and second patch will be sent for -net-next after discussion ? That is ok?
Signature · 1 line
Best regards, Tonghao
Quoted 6 lines · On Tue, Sep 29, 2020 at 4:00 AM <[email protected]> wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
I had focused on the code previously.
The s/w checksum verification cost is significant in a VM with traffic to local destinations. A bridge does not verify transport layer checksums OTOH?
Quoted 41 lines
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +7
-2@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = {VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err) --2.23.0
Quoted 9 lines · Willem de Bruijn
Quoted 6 lines · On Tue, Sep 29, 2020 at 4:00 AM <[email protected]> wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Quoted 5 lines
I had focused on the code previously.
The s/w checksum verification cost is significant in a VM with traffic to local destinations. A bridge does not verify transport layer checksums OTOH?
Hi Willem.
No, think about GRO(In the GRO we don't know packets will be forwarded to other ports or to local). The call tree as below:
+ 5.41% secondary_startup_64
- 1.22% ret_from_fork
....
net_rx_action
napi_poll
virtnet_poll
virtnet_receive
napi_gro_receive
dev_gro_receive
inet_gro_receive
tcp4_gro_receive
__skb_gro_checksum_complete
skb_checksum
__skb_checksum
csum_partial
do_csum
- 1.13% do_csum
$ brctl show bridge name bridge id STP enabled interfaces br0 8000.001122330001 no eth1 eth2
Quoted 41 lines
Quoted 41 lines
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* change the fix-tag--- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/virtio_net.c +7
-2@@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = {VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) +struct virtnet_stat_desc {char desc[ETH_GSTRING_LEN ];size_t offset;@@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev,if (features &NETIF_F_LRO ) offloads = vi->guest_offloads_capable;else - offloads =0 ; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK ; err =virtnet_set_guest_offloads (vi, offloads);if (err) --2.23.0
Signature · 1 line
Best regards, Tonghao
Quoted 12 lines · Tonghao Zhang
Quoted 9 lines · Willem de Bruijn
Quoted 6 lines · On Tue, Sep 29, 2020 at 4:00 AM <[email protected]> wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Quoted 8 lines
Quoted 5 lines
I had focused on the code previously.
The s/w checksum verification cost is significant in a VM with traffic to local destinations. A bridge does not verify transport layer checksums OTOH?
Hi Willem.
No, think about GRO(In the GRO we don't know packets will be forwarded to other ports or to local).
I had expected a pure bridging setup that disables LRO to disable GRO as well.
But if not, then, indeed, the checksum needs to be verified before coalescing. Makes sense.
Quoted 23 lines
The call tree as below:
+ 5.41%secondary_startup_64
- 1.22%ret_from_fork
....
net_rx_action
napi_poll
virtnet_poll
virtnet_receive
napi_gro_receive
dev_gro_receive
inet_gro_receive
tcp4_gro_receive
__skb_gro_checksum_complete
skb_checksum
__skb_checksum
csum_partial
do_csum
- 1.13%do_csum$ brctl show bridge name bridge id STP enabled interfaces br0 8000.001122330001 no eth1 eth2
Quoted 7 lines · On Tue, Sep 29, 2020 at 4:00 AM <[email protected]> wrote:
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Quoted 5 lines
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>
David Miller
maintainerFrom: [email protected]
Date: Tue, 29 Sep 2020 09:58:06 +0800
Quoted 11 lines
From: Tonghao Zhang <[email protected]>
Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance.
Fixes a02e8964eaf9 ("virtio-net: ethtool configurable LRO")Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Cc Willem de Bruijn <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>
Applied and queued up for -stable, thank you.