]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Moved config-related allocations to config_pool and showing its size in memory usage
authorMaria Matejka <mq@ucw.cz>
Tue, 1 Nov 2022 07:56:26 +0000 (08:56 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 1 Nov 2022 15:38:24 +0000 (16:38 +0100)
conf/cf-lex.l
conf/conf.c
conf/conf.h
conf/flowspec.Y
filter/f-util.c
nest/cmds.c

index 28d9ba504e30f67794da5a6bdd7ce9f039e52627..ceedee8a55252c80dbf970ad7d778340659312cf 100644 (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++)
index 025c040e60eeeaf57ec57e1c2757b4e809c4cca4..11c136e77e809b31ca303cb9576b9a686a2f5ae8 100644 (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;
 }
 
index 96c873df8c15e32ad5e5214f83ca82a14a3940b5..5ec924b02f942b6a66645cb156e9530a377b4020 100644 (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)
index dbdbdda5921b8af76067c947516361cf7b61199c..102fed45558cac84742e29d63cc7b75823c03ee8 100644 (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);
 };
index fdb314b50bdc138e5165fa9452683eb15f5e8cb3..d814493ea9e0da9014c576dde10766397fd08a3d 100644 (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;
 
index 8481bf96eead3c4c6eba9113ebe96416fb71b716..bcc8d6c29bc26391e8a8d12b3c84e8963edc6080 100644 (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 });