netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Petr Machata <petrm@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, <netdev@vger.kernel.org>,
	Simon Horman <horms@kernel.org>,
	"Nikolay Aleksandrov" <razor@blackwall.org>,
	Ido Schimmel <idosch@nvidia.com>, <bridge@lists.linux.dev>,
	<mlxsw@nvidia.com>
Subject: Re: [PATCH net-next 02/10] net: bridge: BROPT_FDB_LOCAL_VLAN_0: Look up FDB on VLAN 0 on miss
Date: Tue, 9 Sep 2025 15:34:19 +0200	[thread overview]
Message-ID: <87ecsfr2oq.fsf@nvidia.com> (raw)
In-Reply-To: <20250908191550.11beb208@kernel.org>


Jakub Kicinski <kuba@kernel.org> writes:

> On Thu, 4 Sep 2025 19:07:19 +0200 Petr Machata wrote:
>>  		dst = br_fdb_find_rcu(br, eth_hdr(skb)->h_dest, vid);
>> +		if (unlikely(!dst && vid &&
>> +			     br_opt_get(br, BROPT_FDB_LOCAL_VLAN_0))) {
>
> What does the assembly look like for this? I wonder if we're not better
> off with:
>
> 	unlikely(!dst) && vid && br_opt..

Well, I don't see much there. A couple basic blocks end up reordered is
all I can glean out. I looked at GCC tree dumps which are more
transparent to me, and it's the same exact code in both cases, except
for variable naming, basic block numbering and branch prediction
annotations -- kinda obviously.

> Checking dst will be very fast here, and if we missed we're already 
> on the slow path. So maybe we're better off moving the rest of the
> condition out of the fast path, too?

GCC appears to compile unlikely(A && B && C) as unlikely(A) &&
unlikely(B) && unlikely(C). So it's really much of a muchness -- when we
annotate just !dst, it's going to assume 50/50 on those latter branches,
but we don't really care at that point anymore, because the first 90/10
is going to send us to the slow path. There's a bunch of 50/50 branches
because of __builtin_constant_p's, but those are optimized away in
middle-end. In the end it's the same code, just different basic block
layout decisions.

So we can do either.

  reply	other threads:[~2025-09-09 16:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 17:07 [PATCH net-next 00/10] bridge: Allow keeping local FDB entries only on VLAN 0 Petr Machata
2025-09-04 17:07 ` [PATCH net-next 01/10] net: bridge: Introduce BROPT_FDB_LOCAL_VLAN_0 Petr Machata
2025-09-04 17:07 ` [PATCH net-next 02/10] net: bridge: BROPT_FDB_LOCAL_VLAN_0: Look up FDB on VLAN 0 on miss Petr Machata
2025-09-09  2:15   ` Jakub Kicinski
2025-09-09 13:34     ` Petr Machata [this message]
2025-09-04 17:07 ` [PATCH net-next 03/10] net: bridge: BROPT_FDB_LOCAL_VLAN_0: On port changeaddr, skip per-VLAN FDBs Petr Machata
2025-09-04 17:07 ` [PATCH net-next 04/10] net: bridge: BROPT_FDB_LOCAL_VLAN_0: On bridge " Petr Machata
2025-09-04 17:07 ` [PATCH net-next 05/10] net: bridge: BROPT_FDB_LOCAL_VLAN_0: Skip local FDBs on VLAN creation Petr Machata
2025-09-04 17:07 ` [PATCH net-next 06/10] net: bridge: Introduce UAPI for BR_BOOLOPT_FDB_LOCAL_VLAN_0 Petr Machata
2025-09-04 17:07 ` [PATCH net-next 07/10] selftests: defer: Allow spaces in arguments of deferred commands Petr Machata
2025-09-04 17:07 ` [PATCH net-next 08/10] selftests: defer: Introduce DEFER_PAUSE_ON_FAIL Petr Machata
2025-09-04 17:07 ` [PATCH net-next 09/10] selftests: net: lib.sh: Don't defer failed commands Petr Machata
2025-09-04 17:07 ` [PATCH net-next 10/10] selftests: forwarding: Add test for BR_BOOLOPT_FDB_LOCAL_VLAN_0 Petr Machata
2025-09-06 18:16 ` [PATCH net-next 00/10] bridge: Allow keeping local FDB entries only on VLAN 0 Nikolay Aleksandrov
2025-09-09  2:27 ` Jakub Kicinski
2025-09-09  9:07   ` Nikolay Aleksandrov
2025-09-09  9:19     ` Nikolay Aleksandrov
2025-10-04 13:19     ` Linus Lüssing
2025-10-04 14:31       ` Nikolay Aleksandrov
2025-09-09 12:12   ` Petr Machata
2025-09-12  2:05 ` Jakub Kicinski
2025-09-12  2:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ecsfr2oq.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).