Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93f154b5 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: release dst entry in dev_hard_start_xmit()



One point of contention in high network loads is the dst_release() performed
when a transmited skb is freed. This is because NIC tx completion calls
dev_kree_skb() long after original call to dev_queue_xmit(skb).

CPU cache is cold and the atomic op in dst_release() stalls. On SMP, this is
quite visible if one CPU is 100% handling softirqs for a network device,
since dst_clone() is done by other cpus, involving cache line ping pongs.

It seems right place to release dst is in dev_hard_start_xmit(), for most
devices but ones that are virtual, and some exceptions.

David Miller suggested to define a new device flag, set in alloc_netdev_mq()
(so that most devices set it at init time), and carefuly unset in devices
which dont want a NULL skb->dst in their ndo_start_xmit().

List of devices that must clear this flag is :

- loopback device, because it calls netif_rx() and quoting Patrick :
    "ip_route_input() doesn't accept loopback addresses, so loopback packets
     already need to have a dst_entry attached."
- appletalk/ipddp.c : needs skb->dst in its xmit function

- And all devices that call again dev_queue_xmit() from their xmit function
(as some classifiers need skb->dst) : bonding, vlan, macvlan, eql, ifb, hdlc_fr

Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 496a60cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ static struct net_device * __init ipddp_init(void)
	if (!dev)
		return ERR_PTR(-ENOMEM);

	dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
	strcpy(dev->name, "ipddp%d");

	if (version_printed++ == 0)
+1 −0
Original line number Diff line number Diff line
@@ -5148,6 +5148,7 @@ int bond_create(char *name, struct bond_params *params)
		goto out_rtnl;
	}

	bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
	if (!name) {
		res = dev_alloc_name(bond_dev, "bond%d");
		if (res < 0)
+1 −0
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ static void __init eql_setup(struct net_device *dev)

	dev->type       	= ARPHRD_SLIP;
	dev->tx_queue_len 	= 5;		/* Hands them off fast */
	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
}

static int eql_open(struct net_device *dev)
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ static void ifb_setup(struct net_device *dev)

	dev->flags |= IFF_NOARP;
	dev->flags &= ~IFF_MULTICAST;
	dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
	random_ether_addr(dev->dev_addr);
}

+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ static void loopback_setup(struct net_device *dev)
	dev->tx_queue_len	= 0;
	dev->type		= ARPHRD_LOOPBACK;	/* 0x0001*/
	dev->flags		= IFF_LOOPBACK;
	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
		| NETIF_F_TSO
		| NETIF_F_NO_CSUM
Loading