summaryrefslogtreecommitdiff
path: root/net/bird3/files/patch-11-route-attribute-storage
blob: 5097846203eb69502a3d93999d3f3818d77ee946 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 8b389a503ef56aa69aa456fabebd562abe247119 Mon Sep 17 00:00:00 2001
From: Maria Matejka <mq@ucw.cz>
Date: Tue, 24 Dec 2024 13:12:58 +0100
Subject: [PATCH] Route attribute storage moved to Stonehenge

---
 nest/rt-attr.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index a0f7d5718..8d651efb2 100644
--- nest/rt-attr.c
+++ nest/rt-attr.c
@@ -204,9 +204,7 @@ DOMAIN(attrs) attrs_domain;
 
 pool *rta_pool;
 
-/* Assuming page size of 4096, these are magic values for slab allocation */
-static const uint ea_slab_sizes[] = { 56, 112, 168, 288, 448, 800, 1344 };
-static slab *ea_slab[ARRAY_SIZE(ea_slab_sizes)];
+static stonehenge *ea_sth;
 
 static slab *rte_src_slab;
 
@@ -1583,24 +1581,18 @@ ea_lookup_slow(ea_list *o, u32 squash_upto, enum ea_stored oid)
     return rr;
   }
 
-  struct ea_storage *r = NULL;
   uint elen = ea_list_size(o);
   uint sz = elen + sizeof(struct ea_storage);
-  for (uint i=0; i<ARRAY_SIZE(ea_slab_sizes); i++)
-    if (sz <= ea_slab_sizes[i])
-    {
-      r = sl_alloc(ea_slab[i]);
-      break;
-    }
+  sth_block b = sth_alloc(ea_sth, sz);
 
-  int huge = r ? 0 : EALF_HUGE;;
-  if (huge)
-    r = mb_alloc(rta_pool, sz);
+  struct ea_storage *r = b.block;
 
   ea_list_copy(r->l, o, elen);
   ea_list_ref(r->l);
 
-  r->l->flags |= huge;
+  if (b.large)
+    r->l->flags |= EALF_HUGE;
+
   r->l->stored = oid;
   r->hash_key = h;
   atomic_store_explicit(&r->uc, 1, memory_order_release);
@@ -1668,10 +1660,7 @@ ea_free_deferred(struct deferred_call *dc)
 
   /* And now we can free the object, finally */
   ea_list_unref(r->l);
-  if (r->l->flags & EALF_HUGE)
-    mb_free(r);
-  else
-    sl_free(r);
+  sth_free((sth_block) { r, !!(r->l->flags & EALF_HUGE) });
 
   RTA_UNLOCK;
 }
@@ -1722,9 +1711,7 @@ rta_init(void)
   RTA_LOCK;
   rta_pool = rp_new(&root_pool, attrs_domain.attrs, "Attributes");
 
-  for (uint i=0; i<ARRAY_SIZE(ea_slab_sizes); i++)
-    ea_slab[i] = sl_new(rta_pool, ea_slab_sizes[i]);
-
+  ea_sth = sth_new(rta_pool);
   SPINHASH_INIT(rta_hash_table, RTAH, rta_pool, &global_work_list);
 
   rte_src_init();
-- 
GitLab