* [PATCH] net/ipv4: check RTNH_F_LINKDOWN before ip_ignore_linkdown()
@ 2026-11-02 23:13 Vincent Bernat
2026-11-03 12:24 ` Ido Schimmel
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Bernat @ 2026-11-02 23:13 UTC (permalink / raw)
To: David Ahern, Ido Schimmel, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, netdev
Cc: Vincent Bernat
In commit c0c5a60f0f13 ("net: evaluate
net.ipvX.conf.all.ignore_routes_with_linkdown"), I introduced a small
performance regression of about 5 cycles per lookup by adding several
dependent memory loads through `IN_DEV_ORCONF`.
This patch cancels this regression in the most common case where an
interface is not down.
Here is the distribution before this fix for lookups in a table with
500k /32 routes:
min=128 max=4657 count=994104 batch=24 average=134 95th=134 90th=133 50th=132 mad=0
value │ ┊ count
128 │ 120
129 │ 2232
130 │▒ 25224
131 │▒▒▒▒▒▒▒▒▒▒▒▒▒░ 264264
132 │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░ 516480
133 │▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 126864
134 │▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 21624
The lighter shade of gray is the CDF. Here is the distribution after the
fix:
min=124 max=208839 count=994104 batch=24 average=133 95th=128 90th=127 50th=126 mad=0
value │ ┊ count
124 │ 576
125 │▒▒ 49440
126 │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ 584904
127 │▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 284592
128 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 45288
The median lookup time goes from 132 to 126 cycls. Benchmark were run in
a VM pinned to an isolated CPU and running on an AMD EPYC 8024P (Zen
4c).
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
---
net/ipv4/fib_trie.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index be1e40780ad7..39c8f441601c 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1403,9 +1403,9 @@ bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags,
if (nhc->nhc_flags & RTNH_F_DEAD)
return false;
- if (ip_ignore_linkdown(nhc->nhc_dev) &&
- nhc->nhc_flags & RTNH_F_LINKDOWN &&
- !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE))
+ if (nhc->nhc_flags & RTNH_F_LINKDOWN &&
+ !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE) &&
+ ip_ignore_linkdown(nhc->nhc_dev))
return false;
if (flp->flowi4_oif && flp->flowi4_oif != nhc->nhc_oif)
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/ipv4: check RTNH_F_LINKDOWN before ip_ignore_linkdown()
2026-11-02 23:13 [PATCH] net/ipv4: check RTNH_F_LINKDOWN before ip_ignore_linkdown() Vincent Bernat
@ 2026-11-03 12:24 ` Ido Schimmel
0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2026-11-03 12:24 UTC (permalink / raw)
To: Vincent Bernat
Cc: David Ahern, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, netdev
On Tue, Nov 03, 2026 at 12:13:30AM +0100, Vincent Bernat wrote:
> In commit c0c5a60f0f13 ("net: evaluate
> net.ipvX.conf.all.ignore_routes_with_linkdown"), I introduced a small
> performance regression of about 5 cycles per lookup by adding several
> dependent memory loads through `IN_DEV_ORCONF`.
>
> This patch cancels this regression in the most common case where an
> interface is not down.
>
> Here is the distribution before this fix for lookups in a table with
> 500k /32 routes:
[...]
>
> The median lookup time goes from 132 to 126 cycls. Benchmark were run in
> a VM pinned to an isolated CPU and running on an AMD EPYC 8024P (Zen
> 4c).
>
> Signed-off-by: Vincent Bernat <vincent@bernat.ch>
For net-next:
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 23:13 [PATCH] net/ipv4: check RTNH_F_LINKDOWN before ip_ignore_linkdown() Vincent Bernat
2026-11-03 12:24 ` Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox