bonding: report transmit status to callers
Subsystems (6)
cover bonding: report transmit status to callers
First patches cleanup netpoll, and make sure it provides tx status to its users.
Last patch changes bonding to not pretend packets were sent without error.
By providing more accurate status, TCP stack can avoid adding more packets if the slave qdisc is already full.
This came while testing latest horizon feature in sch_fq, with very low pacing rate flows, but should benefit hosts under stress.
Eric Dumazet (5):
netpoll: remove dev argument from netpoll_send_skb_on_dev()
netpoll: move netpoll_send_skb() out of line
netpoll: netpoll_send_skb() returns transmit status
netpoll: accept NULL np argument in netpoll_send_skb()
bonding: propagate transmit status
drivers/net/bonding/bond_alb.c | 7 ++-- drivers/net/bonding/bond_main.c | 60 ++++++++++++--------------------- drivers/net/macvlan.c | 5 ++- include/linux/if_team.h | 5 +-- include/linux/netpoll.h | 10 +----- include/net/bonding.h | 16 ++++----- net/8021q/vlan_dev.c | 5 ++- net/bridge/br_private.h | 5 +-- net/core/netpoll.c | 29 +++++++++++++--- net/dsa/slave.c | 5 ++- 10 files changed, 65 insertions(+), 82 deletions(-)
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 1/5 netpoll: remove dev argument from netpoll_send_skb_on_dev()
netpoll_send_skb_on_dev() can get the device pointer directly from np->dev
Rename it to __netpoll_send_skb()
Following patch will move netpoll_send_skb() out-of-line.
--- include/linux/netpoll.h | 5 ++--- net/core/netpoll.c | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-)
include/linux/netpoll.h +2 -3
@@ -63,13 +63,12 @@ int netpoll_setup(struct netpoll *np);void __netpoll_cleanup (struct netpoll *np);void __netpoll_free (struct netpoll *np);void netpoll_cleanup (struct netpoll *np); -void netpoll_send_skb_on_dev (struct netpoll *np,struct sk_buff *skb, -struct net_device *dev); +void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb);static inline void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) {unsigned long flags;local_irq_save (flags); -netpoll_send_skb_on_dev (np, skb, np->dev); +__netpoll_send_skb (np, skb);local_irq_restore (flags); }
net/core/netpoll.c +6 -4
@@ -305,17 +305,19 @@ static int netpoll_owner_active(struct net_device *dev) }/* call with IRQ disabled */ -void netpoll_send_skb_on_dev (struct netpoll *np,struct sk_buff *skb, -struct net_device *dev) +void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) {netdev_tx_t status =NETDEV_TX_BUSY ; +struct net_device *dev;unsigned long tries;/* It is up to the caller to keep npinfo alive. */ struct netpoll_info *npinfo;lockdep_assert_irqs_disabled (); - npinfo =rcu_dereference_bh (np->dev->npinfo); + dev = np->dev; + npinfo =rcu_dereference_bh (dev->npinfo); +if (!npinfo || !netif_running (dev) || !netif_device_present (dev)) {dev_kfree_skb_irq (skb);return ;
@@ -358,7 +360,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,schedule_delayed_work (&npinfo->tx_work,0 ); } } -EXPORT_SYMBOL (netpoll_send_skb_on_dev); +EXPORT_SYMBOL (__netpoll_send_skb);void netpoll_send_udp (struct netpoll *np,const char *msg,int len) {
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 2/5 netpoll: move netpoll_send_skb() out of line
In reply to Eric DumazetThere is no need to inline this helper, as we intend to add more code in this function.
--- include/linux/netpoll.h | 9 +-------- net/core/netpoll.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 10 deletions(-)
include/linux/netpoll.h +1 -8
@@ -63,14 +63,7 @@ int netpoll_setup(struct netpoll *np);void __netpoll_cleanup (struct netpoll *np);void __netpoll_free (struct netpoll *np);void netpoll_cleanup (struct netpoll *np); -void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb); -static inline void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) -{ -unsigned long flags; -local_irq_save (flags); -__netpoll_send_skb (np, skb); -local_irq_restore (flags); -} +void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb);#ifdef CONFIG_NETPOLL static inline void *netpoll_poll_lock (struct napi_struct *napi)
net/core/netpoll.c +11 -2
@@ -305,7 +305,7 @@ static int netpoll_owner_active(struct net_device *dev) }/* call with IRQ disabled */ -void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) +static void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) {netdev_tx_t status =NETDEV_TX_BUSY ;struct net_device *dev;
@@ -360,7 +360,16 @@ void __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)schedule_delayed_work (&npinfo->tx_work,0 ); } } -EXPORT_SYMBOL (__netpoll_send_skb); + +void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) +{ +unsigned long flags; + +local_irq_save (flags); +__netpoll_send_skb (np, skb); +local_irq_restore (flags); +} +EXPORT_SYMBOL (netpoll_send_skb);void netpoll_send_udp (struct netpoll *np,const char *msg,int len) {
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 3/5 netpoll: netpoll_send_skb() returns transmit status
In reply to Eric DumazetSome callers want to know if the packet has been sent or dropped, to inform upper stacks.
--- include/linux/netpoll.h | 2 +- net/core/netpoll.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
include/linux/netpoll.h +1 -1
@@ -63,7 +63,7 @@ int netpoll_setup(struct netpoll *np);void __netpoll_cleanup (struct netpoll *np);void __netpoll_free (struct netpoll *np);void netpoll_cleanup (struct netpoll *np); -void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb); +netdev_tx_t netpoll_send_skb (struct netpoll *np,struct sk_buff *skb);#ifdef CONFIG_NETPOLL static inline void *netpoll_poll_lock (struct napi_struct *napi)
net/core/netpoll.c +7 -4
@@ -305,7 +305,7 @@ static int netpoll_owner_active(struct net_device *dev) }/* call with IRQ disabled */ -static void __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) +static netdev_tx_t __netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) {netdev_tx_t status =NETDEV_TX_BUSY ;struct net_device *dev;
@@ -320,7 +320,7 @@ static void __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)if (!npinfo || !netif_running (dev) || !netif_device_present (dev)) {dev_kfree_skb_irq (skb); -return ; +return NET_XMIT_DROP ; }/* don't get messages out of order, and no recursion */
@@ -359,15 +359,18 @@ static void __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)skb_queue_tail (&npinfo->txq, skb);schedule_delayed_work (&npinfo->tx_work,0 ); } +return NETDEV_TX_OK ; } -void netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) +netdev_tx_t netpoll_send_skb (struct netpoll *np,struct sk_buff *skb) {unsigned long flags; +netdev_tx_t ret;local_irq_save (flags); -__netpoll_send_skb (np, skb); + ret =__netpoll_send_skb (np, skb);local_irq_restore (flags); +return ret; }EXPORT_SYMBOL (netpoll_send_skb);
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 4/5 netpoll: accept NULL np argument in netpoll_send_skb()
In reply to Eric Dumazetnetpoll_send_skb() callers seem to leak skb if the np pointer is NULL. While this should not happen, we can make the code more robust.
--- drivers/net/macvlan.c | 5 ++--- include/linux/if_team.h | 5 +---- include/net/bonding.h | 5 +---- net/8021q/vlan_dev.c | 5 ++--- net/bridge/br_private.h | 5 +---- net/core/netpoll.c | 11 ++++++++--- net/dsa/slave.c | 5 ++--- 7 files changed, 17 insertions(+), 24 deletions(-)
drivers/net/macvlan.c +2 -3
@@ -542,12 +542,11 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)static inline netdev_tx_t macvlan_netpoll_send_skb (struct macvlan_dev *vlan,struct sk_buff *skb) {#ifdef CONFIG_NET_POLL_CONTROLLER -if (vlan->netpoll) -netpoll_send_skb (vlan->netpoll, skb); +return netpoll_send_skb (vlan->netpoll, skb);#else BUG (); -#endif return NETDEV_TX_OK ; +#endif } static netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
include/linux/if_team.h +1 -4
@@ -102,10 +102,7 @@ static inline bool team_port_dev_txable(const struct net_device *port_dev)static inline void team_netpoll_send_skb (struct team_port *port,struct sk_buff *skb) { -struct netpoll *np = port->np; - -if (np) -netpoll_send_skb (np, skb); +netpoll_send_skb (port->np, skb); }#else static inline void team_netpoll_send_skb(struct team_port *port,
include/net/bonding.h +1 -4
@@ -507,10 +507,7 @@ static inline unsigned long slave_last_rx(struct bonding *bond,static inline void bond_netpoll_send_skb (const struct slave *slave,struct sk_buff *skb) { -struct netpoll *np = slave->np; - -if (np) -netpoll_send_skb (np, skb); +netpoll_send_skb (slave->np, skb); }#else static inline void bond_netpoll_send_skb(const struct slave *slave,
net/8021q/vlan_dev.c +2 -3
@@ -88,12 +88,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,static inline netdev_tx_t vlan_netpoll_send_skb (struct vlan_dev_priv *vlan,struct sk_buff *skb) {#ifdef CONFIG_NET_POLL_CONTROLLER -if (vlan->netpoll) -netpoll_send_skb (vlan->netpoll, skb); +return netpoll_send_skb (vlan->netpoll, skb);#else BUG (); -#endif return NETDEV_TX_OK ; +#endif } static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
net/bridge/br_private.h +1 -4
@@ -598,10 +598,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev);static inline void br_netpoll_send_skb (const struct net_bridge_port *p,struct sk_buff *skb) { -struct netpoll *np = p->np; - -if (np) -netpoll_send_skb (np, skb); +netpoll_send_skb (p->np, skb); }int br_netpoll_enable (struct net_bridge_port *p);
net/core/netpoll.c +8 -3
@@ -367,9 +367,14 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)unsigned long flags;netdev_tx_t ret; -local_irq_save (flags); - ret =__netpoll_send_skb (np, skb); -local_irq_restore (flags); +if (unlikely (!np)) { +dev_kfree_skb_irq (skb); + ret =NET_XMIT_DROP ; + }else { +local_irq_save (flags); + ret =__netpoll_send_skb (np, skb); +local_irq_restore (flags); + }return ret; }EXPORT_SYMBOL (netpoll_send_skb);
net/dsa/slave.c +2 -3
@@ -445,12 +445,11 @@ static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,#ifdef CONFIG_NET_POLL_CONTROLLER struct dsa_slave_priv *p =netdev_priv (dev); -if (p->netpoll) -netpoll_send_skb (p->netpoll, skb); +return netpoll_send_skb (p->netpoll, skb);#else BUG (); -#endif return NETDEV_TX_OK ; +#endif } static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 5/5 bonding: propagate transmit status
In reply to Eric DumazetCurrently, bonding always returns NETDEV_TX_OK to its caller.
It is worth trying to be more accurate : TCP for instance can have different recovery strategies if it can have more precise status, if packet was dropped by slave qdisc.
This is especially important when host is under stress.
--- drivers/net/bonding/bond_alb.c | 7 ++-- drivers/net/bonding/bond_main.c | 60 ++++++++++++--------------------- include/net/bonding.h | 13 ++++--- 3 files changed, 32 insertions(+), 48 deletions(-)
drivers/net/bonding/bond_alb.c +2 -5
@@ -1318,8 +1318,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, tx_slave->dev->dev_addr); } -bond_dev_queue_xmit (bond, skb, tx_slave->dev); - goto out; +return bond_dev_queue_xmit (bond, skb, tx_slave->dev); }if (tx_slave && bond->params.tlb_dynamic_lb) {
@@ -1329,9 +1328,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, }/* no suitable interface, frame not sent */ -bond_tx_drop (bond->dev, skb); -out: -return NETDEV_TX_OK ; +return bond_tx_drop (bond->dev, skb); }netdev_tx_t bond_tlb_xmit (struct sk_buff *skb,struct net_device *bond_dev)
drivers/net/bonding/bond_main.c +22 -38
138 lines not on this page · raw message
include/net/bonding.h +8 -5
@@ -504,15 +504,17 @@ static inline unsigned long slave_last_rx(struct bonding *bond, }#ifdef CONFIG_NET_POLL_CONTROLLER -static inline void bond_netpoll_send_skb (const struct slave *slave, +static inline netdev_tx_t bond_netpoll_send_skb (const struct slave *slave,struct sk_buff *skb) { -netpoll_send_skb (slave->np, skb); +return netpoll_send_skb (slave->np, skb); }#else -static inline void bond_netpoll_send_skb (const struct slave *slave, +static inline netdev_tx_t bond_netpoll_send_skb (const struct slave *slave,struct sk_buff *skb) { +BUG (); +return NETDEV_TX_OK ; }#endif
@@ -606,7 +608,7 @@ struct bond_net { };int bond_arp_rcv (const struct sk_buff *skb,struct bonding *bond,struct slave *slave); -void bond_dev_queue_xmit (struct bonding *bond,struct sk_buff *skb,struct net_device *slave_dev); +netdev_tx_t bond_dev_queue_xmit (struct bonding *bond,struct sk_buff *skb,struct net_device *slave_dev);int bond_create (struct net *net,const char *name);int bond_create_sysfs (struct bond_net *net);void bond_destroy_sysfs (struct bond_net *net);
@@ -739,10 +741,11 @@ extern struct bond_parm_tbl ad_select_tbl[];/* exported from bond_netlink.c */ extern struct rtnl_link_ops bond_link_ops; -static inline void bond_tx_drop (struct net_device *dev,struct sk_buff *skb) +static inline netdev_tx_t bond_tx_drop (struct net_device *dev,struct sk_buff *skb) {atomic_long_inc (&dev->tx_dropped);dev_kfree_skb_any (skb); +return NET_XMIT_DROP ; }#endif /* _NET_BONDING_H */
Signature · 1 line
2.26.2.526.g744177e7f7-goog
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Thu, 7 May 2020 09:32:17 -0700
Quoted 9 lines
First patches cleanup netpoll, and make sure it provides tx status to its users.
Last patch changes bonding to not pretend packets were sent without error.
By providing more accurate status, TCP stack can avoid adding more packets if the slave qdisc is already full.
This came while testing latest horizon feature in
sch_fq, with very low pacing rate flows, but should benefit hosts under stress.
Looks good, series applied, thanks Eric.