From: Igor Putovny Date: Tue, 4 Mar 2025 15:38:30 +0000 (+0100) Subject: Replace trie linpool with slab X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b36f781430243db481007e55692f3176ad5dcfe2;p=thirdparty%2Fbird.git Replace trie linpool with slab --- diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index da2fc7630..7aeb07014 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -851,7 +851,7 @@ aggregator_init_trie(struct aggregator_proto *p) HASH_INSERT2(p->buckets, AGGR_BUCK, p->p.pool, new_bucket); /* Create root node */ - p->root = aggregator_create_new_node(p->trie_pool); + p->root = aggregator_create_new_node(p->trie_slab); /* * Root node is initialized with NON_FIB status. @@ -872,7 +872,7 @@ aggregator_start(struct proto *P) ASSERT_DIE(p->bucket_pool == NULL); ASSERT_DIE(p->route_pool == NULL); - ASSERT_DIE(p->trie_pool == NULL); + ASSERT_DIE(p->trie_slab == NULL); ASSERT_DIE(p->root == NULL); p->addr_type = p->src->table->addr_type; @@ -890,8 +890,8 @@ aggregator_start(struct proto *P) if (p->aggr_mode == PREFIX_AGGR) { - ASSERT_DIE(p->trie_pool == NULL); - p->trie_pool = lp_new(P->pool); + ASSERT_DIE(p->trie_slab == NULL); + p->trie_slab = sl_new(P->pool, sizeof(struct trie_node)); ASSERT_DIE(p->bucket_list == NULL); ASSERT_DIE(p->bucket_list_size == 0); @@ -926,7 +926,7 @@ aggregator_cleanup(struct proto *P) */ p->bucket_pool = NULL; p->route_pool = NULL; - p->trie_pool = NULL; + p->trie_slab = NULL; p->rte_withdrawal_pool = NULL; p->root = NULL; diff --git a/proto/aggregator/aggregator.h b/proto/aggregator/aggregator.h index 1f2d3533a..31b9a0a59 100644 --- a/proto/aggregator/aggregator.h +++ b/proto/aggregator/aggregator.h @@ -86,7 +86,7 @@ struct aggregator_proto { /* Aggregation trie */ uint addr_type; - linpool *trie_pool; + struct slab *trie_slab; struct trie_node *root; int logging; @@ -152,6 +152,6 @@ void aggregator_aggregate(struct aggregator_proto *p); void aggregator_recalculate(struct aggregator_proto *p, struct aggregator_route *old, struct aggregator_route *new); void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net); -struct trie_node *aggregator_create_new_node(linpool *trie_pool); +struct trie_node *aggregator_create_new_node(struct slab *trie_slab); #endif diff --git a/proto/aggregator/trie.c b/proto/aggregator/trie.c index 07c69049c..a4f1a9a11 100644 --- a/proto/aggregator/trie.c +++ b/proto/aggregator/trie.c @@ -92,13 +92,12 @@ static const u32 ipa_shift[] = { }; /* - * Allocate new node in protocol linpool + * Allocate new node in trie slab */ struct trie_node * -aggregator_create_new_node(linpool *trie_pool) +aggregator_create_new_node(struct slab *trie_slab) { - struct trie_node *node = lp_allocz(trie_pool, sizeof(*node)); - return node; + return sl_allocz(trie_slab); } static inline int @@ -130,6 +129,7 @@ aggregator_remove_node(struct trie_node *node) } memset(node, 0, sizeof(*node)); + sl_free(node); } /* @@ -439,7 +439,7 @@ aggregator_trie_insert_prefix(struct aggregator_proto *p, ip_addr prefix, u32 px if (!node->child[bit]) { - struct trie_node *new = aggregator_create_new_node(p->trie_pool); + struct trie_node *new = aggregator_create_new_node(p->trie_slab); *new = (struct trie_node) { .parent = node, @@ -720,7 +720,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node, */ if (!aggregator_is_bucket_potential(&imaginary_node, imaginary_node_inherited_bucket)) { - struct trie_node *new = aggregator_create_new_node(p->trie_pool); + struct trie_node *new = aggregator_create_new_node(p->trie_slab); *new = imaginary_node; /* Connect new node to the trie */