session: reduce segment reserved bytes 00/25700/4
authorFlorin Coras <fcoras@cisco.com>
Thu, 5 Mar 2020 20:36:40 +0000 (20:36 +0000)
committerDave Barach <openvpp@barachs.net>
Thu, 5 Mar 2020 21:56:28 +0000 (21:56 +0000)
Type: refactor

Rb-trees are no longer maintained in the segment so we don't need to
reserve memory. Keeping the option as a means to avoid underlying infra
(dlmalloc) and alignment overhead.

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I84741e95d015f7b72c60d9dca20be8e0aee6a915

src/svm/fifo_segment.c

index 39856a1..816f711 100644 (file)
@@ -116,7 +116,7 @@ fifo_segment_init (fifo_segment_t * fs)
   fifo_segment_header_t *fsh;
   fifo_segment_slice_t *fss;
   ssvm_shared_header_t *sh;
-  u32 max_chunk_sz, max_chunks;
+  u32 max_chunk_sz;
   uword max_fifo;
   void *oldheap;
   int i;
@@ -159,8 +159,7 @@ fifo_segment_init (fifo_segment_t * fs)
 
   fsh->n_free_bytes = fsh_free_space (fsh);
   fsh->n_cached_bytes = 0;
-  max_chunks = fsh->n_free_bytes / FIFO_SEGMENT_MIN_FIFO_SIZE;
-  fsh->n_reserved_bytes = (max_chunks / 4) * sizeof (rb_node_t);
+  fsh->n_reserved_bytes = clib_min (0.01 * fsh->n_free_bytes, 256 << 10);
   sh->ready = 1;
   return (0);
 }