]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Linpool: default allocation size
authorJan Moskyto Matejka <mq@ucw.cz>
Tue, 16 May 2017 12:31:16 +0000 (14:31 +0200)
committerJan Moskyto Matejka <mq@ucw.cz>
Tue, 16 May 2017 13:34:57 +0000 (15:34 +0200)
14 files changed:
conf/conf.c
filter/filter_test.c
filter/tree_test.c
lib/flowspec_test.c
lib/mempool.c
lib/resource.h
nest/a-path_test.c
nest/a-set_test.c
nest/cli.c
nest/rt-table.c
proto/bgp/bgp.c
proto/static/static.c
sysdep/linux/netlink.c
sysdep/unix/krt.c

index a28378865e9fa5b231bea43f76ae74f3f1fbb302..9978ef23c4da30a7653adb0c0f28c1dd5fb6e1dd 100644 (file)
@@ -89,7 +89,7 @@ struct config *
 config_alloc(const char *name)
 {
   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));
 
   /* Duplication of name string in local linear pool */
index 82efae0b433e649e8015b56a6481867cf3ad252a..be7fd5211cc536735e3d6b854443094536d19c20 100644 (file)
@@ -43,7 +43,7 @@ run_function(const void *parsed_fn_def)
   /* XXX: const -> non-const */
   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);
   rfree(tmp);
 
index e224a559b610cec79b65fbe48215d015956c1b28..5b22a9fe1cf28c29c8800d2c9fdd3637abcb4c05 100644 (file)
@@ -20,7 +20,7 @@ start_conf_env(void)
   bt_bird_init();
 
   pool *p = rp_new(&root_pool, "helper_pool");
-  linpool *l = lp_new(p, 4080);
+  linpool *l = lp_new_default(p);
   cfg_mem = l;
 }
 
index 363361040d48e238dda4fc422f26e7759debf30a..69bc279d65d09ecc49ad2f3674b7ca14575e11bc 100644 (file)
@@ -401,7 +401,7 @@ t_builder4(void)
   resource_init();
 
   struct flow_builder *fb = flow_builder_init(&root_pool);
-  linpool *lp = lp_new(&root_pool, 4096);
+  linpool *lp = lp_new_default(&root_pool);
 
   /* Expectation */
 
@@ -482,7 +482,7 @@ t_builder6(void)
   net_addr_ip6 ip;
 
   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);
   fb->ipv6 = 1;
 
index a8281041d8affa4cc1fbc6eb1546dfe00363520e..3cf9c2d3264b5c9d70f0e68514d5d739eb95c870 100644 (file)
@@ -32,6 +32,8 @@ struct lp_chunk {
   byte data[0];
 };
 
+const int lp_chunk_size = sizeof(struct lp_chunk);
+
 struct linpool {
   resource r;
   byte *ptr, *end;
index 1a0568b48b72b4317504c87da707028e790cbd53..761c6adc1586dee6befab19269bf337f9cb4ce0f 100644 (file)
@@ -65,6 +65,11 @@ void *lp_allocu(linpool *, unsigned size);   /* Unaligned */
 void *lp_allocz(linpool *, unsigned size);     /* With clear */
 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 */
 
 typedef struct slab slab;
index fbf0f8928572ca755ea98637c18d72c477b2f8ed..5e1223968a166856f34cdcb71e9ccfaaf46504d1 100644 (file)
@@ -32,7 +32,7 @@ t_as_path_match(void)
     struct adata *as_path = &empty_as_path;
     u32 first_prepended, last_prepended;
     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] = {};
     int i;
@@ -76,7 +76,7 @@ t_path_format(void)
 
   struct adata 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;
   for (i = 4294967285; i <= 4294967294; i++)
@@ -122,7 +122,7 @@ t_path_include(void)
 
   struct adata 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] = {};
   int i;
@@ -167,7 +167,7 @@ t_as_path_converting(void)
 
   struct adata 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
 
   int i;
index f4588d6567493e20fa4c08d647a43cd649b431fa..a5081f9f4fec4e6f74c71d06bc1544806d28eaef 100644 (file)
@@ -38,7 +38,7 @@ generate_set_sequence(enum set_type type)
 {
   struct adata 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;
   for (i = 0; i < SET_SIZE; i++)
@@ -205,7 +205,7 @@ t_set_ec_format(void)
 
   struct adata 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;
   set_sequence = ec_set_add(lp, set_sequence, i);
index bf8bf127db9175157b59d4be85bd05c194c62307..aceb5770cf5bc0afc1fd44453d05abe1d677e16f 100644 (file)
@@ -313,8 +313,8 @@ cli_new(void *priv)
   c->event->hook = cli_event;
   c->event->data = c;
   c->cont = cli_hello;
-  c->parser_pool = lp_new(c->pool, 4080);
-  c->show_pool = lp_new(c->pool, 4080);
+  c->parser_pool = lp_new_default(c->pool);
+  c->show_pool = lp_new_default(c->pool);
   c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE);
   ev_schedule(c->event);
   return c;
index bed9036edc80875bb58ec364813263d920a7784e..85a951b866bf88ecf91ee54be8c513870db30162 100644 (file)
@@ -1624,7 +1624,7 @@ rt_init(void)
 {
   rta_init();
   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));
   init_list(&routing_tables);
 }
@@ -2304,7 +2304,7 @@ rt_init_hostcache(rtable *tab)
   hc_alloc_table(hc, HC_DEF_ORDER);
   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));
 
   tab->hostcache = hc;
index b9a1d157f8912ffad69b3c4e478838cc278b8845..cccced57e349c0da0a1febc71a089c0aba08b3b2 100644 (file)
@@ -185,8 +185,8 @@ bgp_open(struct bgp_proto *p)
 
   if (!bgp_linpool)
   {
-    bgp_linpool  = lp_new(proto_pool, 4080);
-    bgp_linpool2 = lp_new(proto_pool, 4080);
+    bgp_linpool  = lp_new_default(proto_pool);
+    bgp_linpool2 = lp_new_default(proto_pool);
   }
 
   return 0;
index f74ecee04952758350fde6e7b775575a3030e25f..bb1501a5bf27e4e8194c367a17e6fcbe671d9199 100644 (file)
@@ -410,7 +410,7 @@ static_start(struct proto *P)
   struct static_route *r;
 
   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)
     rt_lock_table(p->igp_table_ip4);
index 083a8d90e87c340223c47b3d7b1aea114da3d9ea..8f44b007acb8390b2ffb3c68d386a8655ad22aea 100644 (file)
@@ -1906,7 +1906,7 @@ nl_open_async(void)
 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);
 }
 
index a1b10cea81a9e40c33197370fb00378684fc02b1..f0241777a7ce5184a4a7d837f5c3970badce5bf7 100644 (file)
@@ -75,7 +75,7 @@ void
 krt_io_init(void)
 {
   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);
   krt_sys_io_init();
 }