Linpool: default allocation size
This commit is contained in:
parent
b880e3ffae
commit
05d47bd53e
14 changed files with 27 additions and 20 deletions
|
@ -89,7 +89,7 @@ struct config *
|
||||||
config_alloc(const char *name)
|
config_alloc(const char *name)
|
||||||
{
|
{
|
||||||
pool *p = rp_new(&root_pool, "Config");
|
pool *p = rp_new(&root_pool, "Config");
|
||||||
linpool *l = lp_new(p, 4080);
|
linpool *l = lp_new_default(p);
|
||||||
struct config *c = lp_allocz(l, sizeof(struct config));
|
struct config *c = lp_allocz(l, sizeof(struct config));
|
||||||
|
|
||||||
/* Duplication of name string in local linear pool */
|
/* Duplication of name string in local linear pool */
|
||||||
|
|
|
@ -43,7 +43,7 @@ run_function(const void *parsed_fn_def)
|
||||||
/* XXX: const -> non-const */
|
/* XXX: const -> non-const */
|
||||||
struct f_inst *f = (struct f_inst *) parsed_fn_def;
|
struct f_inst *f = (struct f_inst *) parsed_fn_def;
|
||||||
|
|
||||||
linpool *tmp = lp_new(&root_pool, 4096);
|
linpool *tmp = lp_new_default(&root_pool);
|
||||||
struct f_val res = f_eval(f, tmp);
|
struct f_val res = f_eval(f, tmp);
|
||||||
rfree(tmp);
|
rfree(tmp);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ start_conf_env(void)
|
||||||
bt_bird_init();
|
bt_bird_init();
|
||||||
|
|
||||||
pool *p = rp_new(&root_pool, "helper_pool");
|
pool *p = rp_new(&root_pool, "helper_pool");
|
||||||
linpool *l = lp_new(p, 4080);
|
linpool *l = lp_new_default(p);
|
||||||
cfg_mem = l;
|
cfg_mem = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ t_builder4(void)
|
||||||
resource_init();
|
resource_init();
|
||||||
|
|
||||||
struct flow_builder *fb = flow_builder_init(&root_pool);
|
struct flow_builder *fb = flow_builder_init(&root_pool);
|
||||||
linpool *lp = lp_new(&root_pool, 4096);
|
linpool *lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
/* Expectation */
|
/* Expectation */
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ t_builder6(void)
|
||||||
net_addr_ip6 ip;
|
net_addr_ip6 ip;
|
||||||
|
|
||||||
resource_init();
|
resource_init();
|
||||||
linpool *lp = lp_new(&root_pool, 4096);
|
linpool *lp = lp_new_default(&root_pool);
|
||||||
struct flow_builder *fb = flow_builder_init(&root_pool);
|
struct flow_builder *fb = flow_builder_init(&root_pool);
|
||||||
fb->ipv6 = 1;
|
fb->ipv6 = 1;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ struct lp_chunk {
|
||||||
byte data[0];
|
byte data[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int lp_chunk_size = sizeof(struct lp_chunk);
|
||||||
|
|
||||||
struct linpool {
|
struct linpool {
|
||||||
resource r;
|
resource r;
|
||||||
byte *ptr, *end;
|
byte *ptr, *end;
|
||||||
|
|
|
@ -65,6 +65,11 @@ void *lp_allocu(linpool *, unsigned size); /* Unaligned */
|
||||||
void *lp_allocz(linpool *, unsigned size); /* With clear */
|
void *lp_allocz(linpool *, unsigned size); /* With clear */
|
||||||
void lp_flush(linpool *); /* Free everything, but leave linpool */
|
void lp_flush(linpool *); /* Free everything, but leave linpool */
|
||||||
|
|
||||||
|
extern const int lp_chunk_size;
|
||||||
|
#define LP_GAS 1024
|
||||||
|
#define LP_GOOD_SIZE(x) (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size)
|
||||||
|
#define lp_new_default(p) lp_new(p, LP_GOOD_SIZE(LP_GAS*4))
|
||||||
|
|
||||||
/* Slabs */
|
/* Slabs */
|
||||||
|
|
||||||
typedef struct slab slab;
|
typedef struct slab slab;
|
||||||
|
|
|
@ -32,7 +32,7 @@ t_as_path_match(void)
|
||||||
struct adata *as_path = &empty_as_path;
|
struct adata *as_path = &empty_as_path;
|
||||||
u32 first_prepended, last_prepended;
|
u32 first_prepended, last_prepended;
|
||||||
first_prepended = last_prepended = 0;
|
first_prepended = last_prepended = 0;
|
||||||
struct linpool *lp = lp_new(&root_pool, 0);
|
struct linpool *lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
struct f_path_mask mask[AS_PATH_LENGTH] = {};
|
struct f_path_mask mask[AS_PATH_LENGTH] = {};
|
||||||
int i;
|
int i;
|
||||||
|
@ -76,7 +76,7 @@ t_path_format(void)
|
||||||
|
|
||||||
struct adata empty_as_path = {};
|
struct adata empty_as_path = {};
|
||||||
struct adata *as_path = &empty_as_path;
|
struct adata *as_path = &empty_as_path;
|
||||||
struct linpool *lp = lp_new(&root_pool, 0);
|
struct linpool *lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
uint i;
|
uint i;
|
||||||
for (i = 4294967285; i <= 4294967294; i++)
|
for (i = 4294967285; i <= 4294967294; i++)
|
||||||
|
@ -122,7 +122,7 @@ t_path_include(void)
|
||||||
|
|
||||||
struct adata empty_as_path = {};
|
struct adata empty_as_path = {};
|
||||||
struct adata *as_path = &empty_as_path;
|
struct adata *as_path = &empty_as_path;
|
||||||
struct linpool *lp = lp_new(&root_pool, 0);
|
struct linpool *lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
u32 as_nums[AS_PATH_LENGTH] = {};
|
u32 as_nums[AS_PATH_LENGTH] = {};
|
||||||
int i;
|
int i;
|
||||||
|
@ -167,7 +167,7 @@ t_as_path_converting(void)
|
||||||
|
|
||||||
struct adata empty_as_path = {};
|
struct adata empty_as_path = {};
|
||||||
struct adata *as_path = &empty_as_path;
|
struct adata *as_path = &empty_as_path;
|
||||||
struct linpool *lp = lp_new(&root_pool, 0);
|
struct linpool *lp = lp_new_default(&root_pool);
|
||||||
#define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10
|
#define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -38,7 +38,7 @@ generate_set_sequence(enum set_type type)
|
||||||
{
|
{
|
||||||
struct adata empty_as_path = {};
|
struct adata empty_as_path = {};
|
||||||
set_sequence = set_sequence_same = set_sequence_higher = set_random = &empty_as_path;
|
set_sequence = set_sequence_same = set_sequence_higher = set_random = &empty_as_path;
|
||||||
lp = lp_new(&root_pool, 0);
|
lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SET_SIZE; i++)
|
for (i = 0; i < SET_SIZE; i++)
|
||||||
|
@ -205,7 +205,7 @@ t_set_ec_format(void)
|
||||||
|
|
||||||
struct adata empty_as_path = {};
|
struct adata empty_as_path = {};
|
||||||
set_sequence = set_sequence_same = set_sequence_higher = set_random = &empty_as_path;
|
set_sequence = set_sequence_same = set_sequence_higher = set_random = &empty_as_path;
|
||||||
lp = lp_new(&root_pool, 0);
|
lp = lp_new_default(&root_pool);
|
||||||
|
|
||||||
u64 i = 0;
|
u64 i = 0;
|
||||||
set_sequence = ec_set_add(lp, set_sequence, i);
|
set_sequence = ec_set_add(lp, set_sequence, i);
|
||||||
|
|
|
@ -313,8 +313,8 @@ cli_new(void *priv)
|
||||||
c->event->hook = cli_event;
|
c->event->hook = cli_event;
|
||||||
c->event->data = c;
|
c->event->data = c;
|
||||||
c->cont = cli_hello;
|
c->cont = cli_hello;
|
||||||
c->parser_pool = lp_new(c->pool, 4080);
|
c->parser_pool = lp_new_default(c->pool);
|
||||||
c->show_pool = lp_new(c->pool, 4080);
|
c->show_pool = lp_new_default(c->pool);
|
||||||
c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE);
|
c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE);
|
||||||
ev_schedule(c->event);
|
ev_schedule(c->event);
|
||||||
return c;
|
return c;
|
||||||
|
|
|
@ -1624,7 +1624,7 @@ rt_init(void)
|
||||||
{
|
{
|
||||||
rta_init();
|
rta_init();
|
||||||
rt_table_pool = rp_new(&root_pool, "Routing tables");
|
rt_table_pool = rp_new(&root_pool, "Routing tables");
|
||||||
rte_update_pool = lp_new(rt_table_pool, 4080);
|
rte_update_pool = lp_new_default(rt_table_pool);
|
||||||
rte_slab = sl_new(rt_table_pool, sizeof(rte));
|
rte_slab = sl_new(rt_table_pool, sizeof(rte));
|
||||||
init_list(&routing_tables);
|
init_list(&routing_tables);
|
||||||
}
|
}
|
||||||
|
@ -2304,7 +2304,7 @@ rt_init_hostcache(rtable *tab)
|
||||||
hc_alloc_table(hc, HC_DEF_ORDER);
|
hc_alloc_table(hc, HC_DEF_ORDER);
|
||||||
hc->slab = sl_new(rt_table_pool, sizeof(struct hostentry));
|
hc->slab = sl_new(rt_table_pool, sizeof(struct hostentry));
|
||||||
|
|
||||||
hc->lp = lp_new(rt_table_pool, 1008);
|
hc->lp = lp_new(rt_table_pool, LP_GOOD_SIZE(1024));
|
||||||
hc->trie = f_new_trie(hc->lp, sizeof(struct f_trie_node));
|
hc->trie = f_new_trie(hc->lp, sizeof(struct f_trie_node));
|
||||||
|
|
||||||
tab->hostcache = hc;
|
tab->hostcache = hc;
|
||||||
|
|
|
@ -185,8 +185,8 @@ bgp_open(struct bgp_proto *p)
|
||||||
|
|
||||||
if (!bgp_linpool)
|
if (!bgp_linpool)
|
||||||
{
|
{
|
||||||
bgp_linpool = lp_new(proto_pool, 4080);
|
bgp_linpool = lp_new_default(proto_pool);
|
||||||
bgp_linpool2 = lp_new(proto_pool, 4080);
|
bgp_linpool2 = lp_new_default(proto_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -410,7 +410,7 @@ static_start(struct proto *P)
|
||||||
struct static_route *r;
|
struct static_route *r;
|
||||||
|
|
||||||
if (!static_lp)
|
if (!static_lp)
|
||||||
static_lp = lp_new(&root_pool, 1008);
|
static_lp = lp_new(&root_pool, LP_GOOD_SIZE(1024));
|
||||||
|
|
||||||
if (p->igp_table_ip4)
|
if (p->igp_table_ip4)
|
||||||
rt_lock_table(p->igp_table_ip4);
|
rt_lock_table(p->igp_table_ip4);
|
||||||
|
|
|
@ -1906,7 +1906,7 @@ nl_open_async(void)
|
||||||
void
|
void
|
||||||
krt_sys_io_init(void)
|
krt_sys_io_init(void)
|
||||||
{
|
{
|
||||||
nl_linpool = lp_new(krt_pool, 4080);
|
nl_linpool = lp_new_default(krt_pool);
|
||||||
HASH_INIT(nl_table_map, krt_pool, 6);
|
HASH_INIT(nl_table_map, krt_pool, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ void
|
||||||
krt_io_init(void)
|
krt_io_init(void)
|
||||||
{
|
{
|
||||||
krt_pool = rp_new(&root_pool, "Kernel Syncer");
|
krt_pool = rp_new(&root_pool, "Kernel Syncer");
|
||||||
krt_filter_lp = lp_new(krt_pool, 4080);
|
krt_filter_lp = lp_new_default(krt_pool);
|
||||||
init_list(&krt_proto_list);
|
init_list(&krt_proto_list);
|
||||||
krt_sys_io_init();
|
krt_sys_io_init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue