0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-17 08:38:42 +00:00

Moved config-related allocations to config_pool and showing its size in memory usage

This commit is contained in:
Maria Matejka 2022-11-01 08:56:26 +01:00
parent 5aebce5e0c
commit 37b6444137
6 changed files with 14 additions and 10 deletions

View File

@ -717,7 +717,7 @@ cf_lex_symbol(const char *data)
static void
cf_lex_init_kh(void)
{
HASH_INIT(kw_hash, &root_pool, KW_ORDER);
HASH_INIT(kw_hash, config_pool, KW_ORDER);
struct keyword *k;
for (k=keyword_list; k->name; k++)

View File

@ -61,6 +61,7 @@
static jmp_buf conf_jmpbuf;
struct config *config, *new_config;
pool *config_pool;
static struct config *old_config; /* Old configuration */
static struct config *future_config; /* New config held here if recon requested during recon */
@ -89,7 +90,7 @@ int undo_available; /* Undo was not requested from last reconfiguration */
struct config *
config_alloc(const char *name)
{
pool *p = rp_new(&root_pool, "Config");
pool *p = rp_new(config_pool, "Config");
linpool *l = lp_new_default(p);
struct config *c = lp_allocz(l, sizeof(struct config));
@ -491,10 +492,12 @@ config_timeout(timer *t UNUSED)
void
config_init(void)
{
config_event = ev_new(&root_pool);
config_pool = rp_new(&root_pool, "Configurations");
config_event = ev_new(config_pool);
config_event->hook = config_done;
config_timer = tm_new(&root_pool);
config_timer = tm_new(config_pool);
config_timer->hook = config_timeout;
}

View File

@ -96,7 +96,7 @@ void order_shutdown(int gr);
/* Pools */
extern pool *config_pool;
extern linpool *cfg_mem;
#define cfg_alloc(size) lp_alloc(cfg_mem, size)

View File

@ -180,7 +180,7 @@ flow6_opts:
flow_builder_init:
{
if (this_flow == NULL)
this_flow = flow_builder_init(&root_pool);
this_flow = flow_builder_init(config_pool); /* FIXME: This should be allocated from tmp in future */
else
flow_builder_clear(this_flow);
};

View File

@ -128,11 +128,11 @@ ca_lookup(pool *p, const char *name, int f_type)
static int inited = 0;
if (!inited) {
idm_init(&ca_idm, &root_pool, 8);
HASH_INIT(ca_hash, &root_pool, CA_ORDER);
idm_init(&ca_idm, config_pool, 8);
HASH_INIT(ca_hash, config_pool, CA_ORDER);
ca_storage_max = 256;
ca_storage = mb_allocz(&root_pool, sizeof(struct ca_storage *) * ca_storage_max);
ca_storage = mb_allocz(config_pool, sizeof(struct ca_storage *) * ca_storage_max);
inited++;
}
@ -152,7 +152,7 @@ ca_lookup(pool *p, const char *name, int f_type)
ca_storage = mb_realloc(ca_storage, sizeof(struct ca_storage *) * ca_storage_max * 2);
}
cas = mb_allocz(&root_pool, sizeof(struct ca_storage) + strlen(name) + 1);
cas = mb_allocz(config_pool, sizeof(struct ca_storage) + strlen(name) + 1);
cas->fda = f_new_dynamic_attr(ea_type, f_type, EA_CUSTOM(id));
cas->uc = 1;

View File

@ -118,6 +118,7 @@ cmd_show_memory(void)
print_size("Routing tables:", rmemsize(rt_table_pool));
print_size("Route attributes:", rmemsize(rta_pool));
print_size("Protocols:", rmemsize(proto_pool));
print_size("Current config:", rmemsize(config_pool));
struct resmem total = rmemsize(&root_pool);
#ifdef HAVE_MMAP
print_size("Standby memory:", (struct resmem) { .overhead = page_size * *pages_kept });