net: Remove likely from l3mdev_master_ifindex_by_index
Subsystems (3)
PATCH 1/1 net: Remove likely from l3mdev_master_ifindex_by_index
The likely() annotation in l3mdev_master_ifindex_by_index() has been found to be incorrect 100% of the time in real-world workloads (e.g., web servers).
Annotated branches shows the following in these servers:
correct incorrect % Function File Line 0 169053813 100 l3mdev_master_ifindex_by_index l3mdev.h 81
This is happening because l3mdev_master_ifindex_by_index() is called from __inet_check_established(), which calls l3mdev_master_ifindex_by_index() passing the socked bounded interface.
l3mdev_master_ifindex_by_index(net, sk->sk_bound_dev_if);
Since most sockets are not going to be bound to a network device, the likely() is giving the wrong assumption.
Remove the likely() annotation to ensure more accurate branch prediction.
--- include/net/l3mdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/l3mdev.h +1 -1
@@ -78,7 +78,7 @@ static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)struct net_device *dev;int rc =0 ; -if (likely (ifindex)) { +if (ifindex) {rcu_read_lock (); dev =dev_get_by_index_rcu (net, ifindex);
Signature · 1 line
2.43.5
Quoted 18 lines · Breno Leitao
The
likely()annotation inl3mdev_master_ifindex_by_index()has been found to be incorrect 100% of the time in real-world workloads (e.g., web servers).Annotated branches shows the following in these servers:
correct incorrect % Function File Line 0 169053813 100 l3mdev_master_ifindex_by_index l3mdev.h 81This is happening because
l3mdev_master_ifindex_by_index()is called from__inet_check_established(), which callsl3mdev_master_ifindex_by_index()passing the socked bounded interface.l3mdev_master_ifindex_by_index(net, sk->sk_bound_dev_if);Since most sockets are not going to be bound to a network device, the
likely()is giving the wrong assumption.
Quoted 8 lines
Remove the
likely()annotation to ensure more accurate branch prediction.Signed-off-by Breno Leitao <[email protected]>--- include/net/l3mdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Eric Dumazet
Reviewed-byQuoted 23 lines · David Ahern
Quoted 21 lines · Breno Leitao
The
likely()annotation inl3mdev_master_ifindex_by_index()has been found to be incorrect 100% of the time in real-world workloads (e.g., web servers).Annotated branches shows the following in these servers:
correct incorrect % Function File Line
0 169053813 100l3mdev_master_ifindex_by_indexl3mdev.h81This is happening because
l3mdev_master_ifindex_by_index()is called from__inet_check_established(), which callsl3mdev_master_ifindex_by_index()passing the socked bounded interface.l3mdev_master_ifindex_by_index(net, sk->sk_bound_dev_if);Since most sockets are not going to be bound to a network device, the
likely()is giving the wrong assumption.Remove the
likely()annotation to ensure more accurate branch prediction.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Breno Leitao <[email protected]>--- include/net/l3mdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by David Ahern <[email protected]>
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 8 Oct 2024 09:32:04 -0700 you wrote:
The
likely()annotation inl3mdev_master_ifindex_by_index()has been found to be incorrect 100% of the time in real-world workloads (e.g., web servers).Annotated branches shows the following in these servers:
correct incorrect % Function File Line 0 169053813 100 l3mdev_master_ifindex_by_index l3mdev.h 81[...]
Here is the summary with links:
- [net-next] net: Remove likely from l3mdev_master_ifindex_by_index
https://git.kernel.org/netdev/net-next/c/9e542ff8b79a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html