net: better IFF_XMIT_DST_RELEASE support
Testing xmit_more support with netperf and connected UDP sockets, I found strange dst refcount false sharing. Current handling of IFF_XMIT_DST_RELEASE is not optimal. Dropping dst in validate_xmit_skb() is certainly too late in case packet was queued by cpu X but dequeued by cpu Y The logical point to take care of drop/force is in __dev_queue_xmit() before even taking qdisc lock. As Julian Anastasov pointed out, need for skb_dst() might come from some packet schedulers or classifiers. This patch adds new helper to cleanly express needs of various drivers or qdiscs/classifiers. Drivers that need skb_dst() in their ndo_start_xmit() should call following helper in their setup instead of the prior : dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; -> netif_keep_dst(dev); Instead of using a single bit, we use two bits, one being eventually rebuilt in bonding/team drivers. The other one, is permanent and blocks IFF_XMIT_DST_RELEASE being rebuilt in bonding/team. Eventually, we could add something smarter later. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

orang tua
fe971b95c2
melakukan
0287587884
@@ -2665,12 +2665,6 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
|
||||
if (skb->next)
|
||||
return skb;
|
||||
|
||||
/* If device doesn't need skb->dst, release it right now while
|
||||
* its hot in this cpu cache
|
||||
*/
|
||||
if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
|
||||
skb_dst_drop(skb);
|
||||
|
||||
features = netif_skb_features(skb);
|
||||
skb = validate_xmit_vlan(skb, features);
|
||||
if (unlikely(!skb))
|
||||
@@ -2811,8 +2805,6 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
|
||||
* waiting to be sent out; and the qdisc is not running -
|
||||
* xmit the skb directly.
|
||||
*/
|
||||
if (!(dev->priv_flags & IFF_XMIT_DST_RELEASE))
|
||||
skb_dst_force(skb);
|
||||
|
||||
qdisc_bstats_update(q, skb);
|
||||
|
||||
@@ -2827,7 +2819,6 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
|
||||
|
||||
rc = NET_XMIT_SUCCESS;
|
||||
} else {
|
||||
skb_dst_force(skb);
|
||||
rc = q->enqueue(skb, q) & NET_XMIT_MASK;
|
||||
if (qdisc_run_begin(q)) {
|
||||
if (unlikely(contended)) {
|
||||
@@ -2924,6 +2915,14 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
|
||||
|
||||
skb_update_prio(skb);
|
||||
|
||||
/* If device/qdisc don't need skb->dst, release it right now while
|
||||
* its hot in this cpu cache.
|
||||
*/
|
||||
if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
|
||||
skb_dst_drop(skb);
|
||||
else
|
||||
skb_dst_force(skb);
|
||||
|
||||
txq = netdev_pick_tx(dev, skb, accel_priv);
|
||||
q = rcu_dereference_bh(txq->qdisc);
|
||||
|
||||
@@ -6674,7 +6673,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
|
||||
INIT_LIST_HEAD(&dev->adj_list.lower);
|
||||
INIT_LIST_HEAD(&dev->all_adj_list.upper);
|
||||
INIT_LIST_HEAD(&dev->all_adj_list.lower);
|
||||
dev->priv_flags = IFF_XMIT_DST_RELEASE;
|
||||
dev->priv_flags = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM;
|
||||
setup(dev);
|
||||
|
||||
dev->num_tx_queues = txqs;
|
||||
|
Reference in New Issue
Block a user