]> git.ipfire.org Git - thirdparty/linux.git/commit
net: optimize eth_type_trans() vs CONFIG_STACKPROTECTOR_STRONG=y
authorEric Dumazet <edumazet@google.com>
Fri, 21 Nov 2025 06:17:25 +0000 (06:17 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 25 Nov 2025 03:27:31 +0000 (19:27 -0800)
commitec1e48e97febbf7f87fc150793af2eda7223815c
treeb34dae58d71044b81587b6083c86fdb5d8cda3e5
parente254c212cd9cabb9469a1282c4c91ccc6180bf51
net: optimize eth_type_trans() vs CONFIG_STACKPROTECTOR_STRONG=y

Some platforms exhibit very high costs with CONFIG_STACKPROTECTOR_STRONG=y
when a function needs to pass the address of a local variable to external
functions.

eth_type_trans() (and its callers) is showing this anomaly on AMD EPYC 7B12
platforms (and maybe others).

We could :

1) inline eth_type_trans()

   This would help if its callers also has the same issue, and the canary cost
   would be paid by the callers already.

   This is a bit cumbersome because netdev_uses_dsa() is pulling
   whole <net/dsa.h> definitions.

2) Compile net/ethernet/eth.c with -fno-stack-protector

   This would weaken security.

3) Hack eth_type_trans() to temporarily use skb->dev as a place holder
   if skb_header_pointer() needs to pull 2 bytes not present in skb->head.

This patch implements 3), and brings a 5% improvement on TX/RX intensive
workload (tcp_rr 10,000 flows) on AMD EPYC 7B12.

Removing CONFIG_STACKPROTECTOR_STRONG on this platform can improve
performance by 25 %.
This means eth_type_trans() issue is not an isolated artifact.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20251121061725.206675-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethernet/eth.c