vppinfra: don't account vec_header_t size twice in the pool header 43/35443/3
authorDamjan Marion <damarion@cisco.com>
Thu, 24 Feb 2022 23:19:26 +0000 (00:19 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 14 Mar 2022 17:55:19 +0000 (17:55 +0000)
Type: fix
Change-Id: I298d2a5067f7949002e6c010f892553f1eb9f477
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/pool.c
src/vppinfra/pool.h

index c2f587a..2539845 100644 (file)
@@ -55,7 +55,8 @@ _pool_init_fixed (void **pool_ptr, u32 elt_size, u32 max_elts)
   ASSERT (elt_size);
   ASSERT (max_elts);
 
-  vector_size = pool_aligned_header_bytes + (u64) elt_size *max_elts;
+  vector_size =
+    vec_header_bytes (pool_aligned_header_bytes) + (u64) elt_size * max_elts;
   free_index_size = vec_header_bytes (0) + sizeof (u32) * max_elts;
 
   /* Round up to a cache line boundary */
@@ -85,7 +86,7 @@ _pool_init_fixed (void **pool_ptr, u32 elt_size, u32 max_elts)
   /* First comes the pool header */
   fh = (pool_header_t *) mmap_base;
   /* Find the user vector pointer */
-  v = (u8 *) (mmap_base + pool_aligned_header_bytes);
+  v = (u8 *) (mmap_base + vec_header_bytes (pool_aligned_header_bytes));
   /* Finally, the vector header */
   vh = _vec_find (v);
 
index 9dd05a3..284e23d 100644 (file)
@@ -68,8 +68,8 @@ typedef struct
 } pool_header_t;
 
 /** Align pool header so that pointers are naturally aligned. */
-#define pool_aligned_header_bytes \
-  vec_aligned_header_bytes (sizeof (pool_header_t), sizeof (void *))
+#define pool_aligned_header_bytes                                             \
+  round_pow2 (sizeof (pool_header_t), sizeof (void *))
 
 /** Get pool header from user pool pointer */
 always_inline pool_header_t *