]> git.baikalelectronics.ru Git - kernel.git/commit
net: slightly optimize eth_type_trans
authorLi RongQing <lirongqing@baidu.com>
Tue, 13 Nov 2018 01:34:31 +0000 (09:34 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 15 Nov 2018 23:10:59 +0000 (15:10 -0800)
commit19eb7e4c9579b7ca3226c81f8b7f63c64a007df7
tree0c8672578e4d0a9f5c60ad6310ccb55dc47f668f
parentf5d0b13c0e39019c0ce8b3d7e9bde32dbb729409
net: slightly optimize eth_type_trans

netperf udp stream shows that eth_type_trans takes certain cpu,
so adjust the mac address check order, and firstly check if it
is device address, and only check if it is multicast address
only if not the device address.

After this change:
To unicast, and skb dst mac is device mac, this is most of time
reduce a comparision
To unicast, and skb dst mac is not device mac, nothing change
To multicast, increase a comparision

Before:
1.03%  [kernel]          [k] eth_type_trans

After:
0.78%  [kernel]          [k] eth_type_trans

Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethernet/eth.c