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;
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);
/* 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;
}
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();