* [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index
@ 2024-10-08 16:32 Breno Leitao
2024-10-08 18:25 ` David Ahern
2024-10-10 10:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Breno Leitao @ 2024-10-08 16:32 UTC (permalink / raw)
To: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: kernel-team, open list:L3MDEV, open list
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.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
include/net/l3mdev.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 031c661aa14d..2d6141f28b53 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -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);
--
2.43.5
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index
2024-10-08 16:32 [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index Breno Leitao
@ 2024-10-08 18:25 ` David Ahern
2024-10-09 13:54 ` Eric Dumazet
2024-10-10 10:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2024-10-08 18:25 UTC (permalink / raw)
To: Breno Leitao, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: kernel-team, open list:L3MDEV, open list
On 10/8/24 10:32 AM, Breno Leitao wrote:
> 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.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> include/net/l3mdev.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index
2024-10-08 18:25 ` David Ahern
@ 2024-10-09 13:54 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-10-09 13:54 UTC (permalink / raw)
To: David Ahern
Cc: Breno Leitao, David S. Miller, Jakub Kicinski, Paolo Abeni,
kernel-team, open list:L3MDEV, open list
On Tue, Oct 8, 2024 at 8:25 PM David Ahern <dsahern@kernel.org> wrote:
>
> On 10/8/24 10:32 AM, Breno Leitao wrote:
> > 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.
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> > include/net/l3mdev.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index
2024-10-08 16:32 [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index Breno Leitao
2024-10-08 18:25 ` David Ahern
@ 2024-10-10 10:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-10 10:20 UTC (permalink / raw)
To: Breno Leitao
Cc: dsahern, davem, edumazet, kuba, pabeni, kernel-team, netdev,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 8 Oct 2024 09:32:04 -0700 you wrote:
> 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
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-10 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-08 16:32 [PATCH net-next] net: Remove likely from l3mdev_master_ifindex_by_index Breno Leitao
2024-10-08 18:25 ` David Ahern
2024-10-09 13:54 ` Eric Dumazet
2024-10-10 10:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®