From: Maxime Leroy <maxime@leroys.fr>
To: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org, Maxime Leroy <maxime@leroys.fr>
Subject: [PATCH v1 5/5] fib6: speed up tbl8 reservation accounting
Date: Fri, 22 May 2026 16:58:54 +0200 [thread overview]
Message-ID: <20260522145855.1748406-6-maxime@leroys.fr> (raw)
In-Reply-To: <20260522145855.1748406-1-maxime@leroys.fr>
Replace the local count_empty_levels() helper, which issued up to 13
rte_rib6_get_nxt() calls each descending the binary tree from root,
with the new __rte_internal rte_rib6_count_empty_supernets(). The
latter descends once and consults the valid_descendants counter
maintained inside rte_rib6, answering all byte boundary questions
in O(tree depth) with O(1) work per boundary.
For a /128 ADD with ancestors at every byte boundary, this reduces
the worst-case query cost from 13 trie descents to 1.
Signed-off-by: Maxime Leroy <maxime@leroys.fr>
---
lib/fib/trie.c | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/lib/fib/trie.c b/lib/fib/trie.c
index 44b90f72ff..b6ef626fd4 100644
--- a/lib/fib/trie.c
+++ b/lib/fib/trie.c
@@ -13,6 +13,7 @@
#include <rte_rib6.h>
#include <rte_fib6.h>
+#include <rib6_internal.h>
#include "fib_log.h"
#include "trie.h"
@@ -534,31 +535,6 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
return 0;
}
-/*
- * Count byte boundaries between 24 and CEIL(depth, 8) where the
- * supernet of ip has no descendant in the RIB. This is the number of
- * new tbl8 levels an ADD of ip/depth would introduce, or the number
- * to free at DEL once the prefix has been removed from the RIB.
- *
- * A NULL answer at level L propagates upwards: narrower supernets at
- * L+8, L+16, ... are subsets of S_L and cannot contain descendants
- * either. The loop stops at the first NULL and tallies the remaining
- * boundaries in one shot.
- */
-static uint8_t
-count_empty_levels(struct rte_rib6 *rib, const struct rte_ipv6_addr *ip,
- uint8_t depth)
-{
- uint8_t level, top = RTE_ALIGN_CEIL(depth, 8);
-
- for (level = 24; level < top; level += 8) {
- if (rte_rib6_get_nxt(rib, ip, level, NULL,
- RTE_RIB6_GET_NXT_COVER) == NULL)
- return (top - level) >> 3;
- }
- return 0;
-}
-
int
trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
uint8_t depth, uint64_t next_hop, int op)
@@ -596,7 +572,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
return 0;
}
- new_levels = count_empty_levels(rib, &ip_masked, depth);
+ new_levels = rte_rib6_count_empty_supernets(rib, &ip_masked, depth);
if (dp->rsvd_tbl8s + new_levels > dp->number_tbl8s)
return -ENOSPC;
@@ -635,7 +611,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
if (ret != 0)
return ret;
rte_rib6_remove(rib, &ip_masked, depth);
- dp->rsvd_tbl8s -= count_empty_levels(rib, &ip_masked, depth);
+ dp->rsvd_tbl8s -= rte_rib6_count_empty_supernets(rib, &ip_masked, depth);
return 0;
default:
break;
--
2.43.0
next prev parent reply other threads:[~2026-05-22 14:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 9:50 [RFC 0/3] fib: tbl8 reservation drift reproducer and proposed fix Maxime Leroy
2026-05-07 9:50 ` [RFC 1/3] fib6: fix tbl8 reservation drift in trie Maxime Leroy
2026-05-07 9:50 ` [RFC 2/3] test/fib6: add reproducer for tbl8 reservation drift Maxime Leroy
2026-05-07 9:50 ` [RFC 3/3] fib: drop redundant tbl8 reservation counter Maxime Leroy
2026-05-07 19:02 ` [RFC 0/3] fib: tbl8 reservation drift reproducer and proposed fix Stephen Hemminger
2026-05-11 7:29 ` Maxime Leroy
2026-05-22 14:58 ` [PATCH v1 0/5] fib6: fix tbl8 reservation drift Maxime Leroy
2026-05-22 14:58 ` [PATCH v1 1/5] fib6: fix tbl8 reservation drift in trie Maxime Leroy
2026-06-05 13:03 ` [PATCH 1/3] " Vladimir Medvedkin
2026-05-22 14:58 ` [PATCH v1 2/5] test/fib6: add reproducer for tbl8 reservation drift Maxime Leroy
2026-05-22 14:58 ` [PATCH v1 3/5] test/fib6: extended drift test cases Maxime Leroy
2026-05-22 14:58 ` [PATCH v1 4/5] rib: track valid descendant count per node Maxime Leroy
2026-05-22 14:58 ` Maxime Leroy [this message]
2026-06-05 13:04 ` [PATCH v1 0/5] fib6: fix tbl8 reservation drift Medvedkin, Vladimir
2026-06-17 8:23 ` [PATCH v2 0/3] " Maxime Leroy
2026-06-17 8:23 ` [PATCH v2 1/3] fib6: fix tbl8 reservation drift in trie Maxime Leroy
2026-06-17 8:23 ` [PATCH v2 2/3] test/fib6: add reproducer for tbl8 reservation drift Maxime Leroy
2026-06-17 8:24 ` [PATCH v2 3/3] test/fib6: extended drift test cases Maxime Leroy
2026-07-01 10:27 ` [PATCH v2 0/3] fib6: fix tbl8 reservation drift David Marchand
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=20260522145855.1748406-6-maxime@leroys.fr \
--to=maxime@leroys.fr \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=vladimir.medvedkin@intel.com \
/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