Re: [PATCH net 1/2] geneve, vxlan: Don't check skb_dst() twice
Le 15/10/2018 à 13:08, Stefano Brivio a écrit : > On Mon, 15 Oct 2018 12:19:41 +0200 > Nicolas Dichtel wrote: > >> Le 12/10/2018 à 23:53, Stefano Brivio a écrit : >>> Commit f15ca723c1eb ("net: don't call update_pmtu unconditionally") avoids >>> that we try updating PMTU for a non-existent destination, but didn't clean >>> up cases where the check was already explicit. Drop those redundant checks. >>> >> Yes, I leave them to avoid calculating the new mtu value when not needed. We >> are >> in the xmit path. > > Before 2/2 of this series, though, we call skb_dst_update_pmtu() (and > in turn dst->ops->update_pmtu()) for *every* packet with a dst, which Not if dst is of type md_dst_ops. > I'd dare saying is by far the most common case. Besides, 2/2 needs > anyway to calculate the MTU to fix a bug. > > So I think this is a vast improvement overall. Fair point.
Re: [PATCH net 1/2] geneve, vxlan: Don't check skb_dst() twice
On Mon, 15 Oct 2018 12:19:41 +0200 Nicolas Dichtel wrote: > Le 12/10/2018 à 23:53, Stefano Brivio a écrit : > > Commit f15ca723c1eb ("net: don't call update_pmtu unconditionally") avoids > > that we try updating PMTU for a non-existent destination, but didn't clean > > up cases where the check was already explicit. Drop those redundant checks. > > > Yes, I leave them to avoid calculating the new mtu value when not needed. We > are > in the xmit path. Before 2/2 of this series, though, we call skb_dst_update_pmtu() (and in turn dst->ops->update_pmtu()) for *every* packet with a dst, which I'd dare saying is by far the most common case. Besides, 2/2 needs anyway to calculate the MTU to fix a bug. So I think this is a vast improvement overall. If we want to improve this further and avoid any indirect calls in the most common path, we would need to cache the MTU in the dst -- it's probably doable, but I would fix the specific issue addressed by 2/2 first. -- Stefano
Re: [PATCH net 1/2] geneve, vxlan: Don't check skb_dst() twice
Le 12/10/2018 à 23:53, Stefano Brivio a écrit : > Commit f15ca723c1eb ("net: don't call update_pmtu unconditionally") avoids > that we try updating PMTU for a non-existent destination, but didn't clean > up cases where the check was already explicit. Drop those redundant checks. Yes, I leave them to avoid calculating the new mtu value when not needed. We are in the xmit path. As skb_dst_update_pmtu() is inlined, we probably don't care, but gcc could still decide to not inline it. Regards, Nicolas
[PATCH net 1/2] geneve, vxlan: Don't check skb_dst() twice
Commit f15ca723c1eb ("net: don't call update_pmtu unconditionally") avoids that we try updating PMTU for a non-existent destination, but didn't clean up cases where the check was already explicit. Drop those redundant checks. Signed-off-by: Stefano Brivio Reviewed-by: Sabrina Dubroca --- drivers/net/geneve.c | 15 --- drivers/net/vxlan.c | 12 ++-- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 6acb6b5718b9..61c4bfbeb41c 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -830,12 +830,8 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, if (IS_ERR(rt)) return PTR_ERR(rt); - if (skb_dst(skb)) { - int mtu = dst_mtu(>dst) - GENEVE_IPV4_HLEN - - info->options_len; - - skb_dst_update_pmtu(skb, mtu); - } + skb_dst_update_pmtu(skb, dst_mtu(>dst) - +GENEVE_IPV4_HLEN - info->options_len); sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); if (geneve->collect_md) { @@ -876,11 +872,8 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, if (IS_ERR(dst)) return PTR_ERR(dst); - if (skb_dst(skb)) { - int mtu = dst_mtu(dst) - GENEVE_IPV6_HLEN - info->options_len; - - skb_dst_update_pmtu(skb, mtu); - } + skb_dst_update_pmtu(skb, dst_mtu(dst) - +GENEVE_IPV6_HLEN - info->options_len); sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); if (geneve->collect_md) { diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 2b8da2b7e721..22e0ce592e07 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2194,11 +2194,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, } ndst = >dst; - if (skb_dst(skb)) { - int mtu = dst_mtu(ndst) - VXLAN_HEADROOM; - - skb_dst_update_pmtu(skb, mtu); - } + skb_dst_update_pmtu(skb, dst_mtu(ndst) - VXLAN_HEADROOM); tos = ip_tunnel_ecn_encap(tos, old_iph, skb); ttl = ttl ? : ip4_dst_hoplimit(>dst); @@ -2235,11 +2231,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, goto out_unlock; } - if (skb_dst(skb)) { - int mtu = dst_mtu(ndst) - VXLAN6_HEADROOM; - - skb_dst_update_pmtu(skb, mtu); - } + skb_dst_update_pmtu(skb, dst_mtu(ndst) - VXLAN6_HEADROOM); tos = ip_tunnel_ecn_encap(tos, old_iph, skb); ttl = ttl ? : ip6_dst_hoplimit(ndst); -- 2.19.1