From 37b644413723670928f6b54f2abe0c852eb0b652 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 1 Nov 2022 08:56:26 +0100 Subject: [PATCH] Moved config-related allocations to config_pool and showing its size in memory usage --- conf/cf-lex.l | 2 +- conf/conf.c | 9 ++++++--- conf/conf.h | 2 +- conf/flowspec.Y | 2 +- filter/f-util.c | 8 ++++---- nest/cmds.c | 1 + 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 28d9ba50..ceedee8a 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -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++) diff --git a/conf/conf.c b/conf/conf.c index 025c040e..11c136e7 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -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; } diff --git a/conf/conf.h b/conf/conf.h index 96c873df..5ec924b0 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -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) diff --git a/conf/flowspec.Y b/conf/flowspec.Y index dbdbdda5..102fed45 100644 --- a/conf/flowspec.Y +++ b/conf/flowspec.Y @@ -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); }; diff --git a/filter/f-util.c b/filter/f-util.c index fdb314b5..d814493e 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -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; diff --git a/nest/cmds.c b/nest/cmds.c index 8481bf96..bcc8d6c2 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -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 });