aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-03-17 17:54:48 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-03-17 20:22:36 +0000
commit2b702da86c42267682b30a888299b89718bc46e8 (patch)
treee3ae01e48c7aa191e3c7739ff711138b04d88f89 /src/vppinfra
parentd591b82cc89ab88862af969f0405e4a6b1d4029a (diff)
vppinfra: move hash bitmap out of vec header
Type: refactor Change-Id: Ibd29a717eaf12d795b3bceb31835d6fc655268b1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/hash.c12
-rw-r--r--src/vppinfra/hash.h7
2 files changed, 11 insertions, 8 deletions
diff --git a/src/vppinfra/hash.c b/src/vppinfra/hash.c
index 63dab989852..f36ce831d25 100644
--- a/src/vppinfra/hash.c
+++ b/src/vppinfra/hash.c
@@ -753,14 +753,19 @@ _hash_create (uword elts, hash_t * h_user)
/* data bytes: */
(elts << log2_pair_size) * sizeof (hash_pair_t),
/* header bytes: */
- sizeof (h[0]) +
- (elts / BITS (h->is_user[0])) * sizeof (h->is_user[0]),
+ sizeof (h[0]),
/* alignment */ sizeof (hash_pair_t));
h = hash_header (v);
if (h_user)
- h[0] = h_user[0];
+ {
+ h[0] = h_user[0];
+ h->is_user = 0;
+ }
+ vec_validate_aligned (
+ h->is_user, ((elts / BITS (h->is_user[0])) * sizeof (h->is_user[0])) - 1,
+ CLIB_CACHE_LINE_BYTES);
h->log2_pair_size = log2_pair_size;
h->elts = 0;
@@ -800,6 +805,7 @@ _hash_free (void *v)
clib_mem_free (p->indirect.pairs);
}
+ vec_free (h->is_user);
vec_free_header (h);
return 0;
diff --git a/src/vppinfra/hash.h b/src/vppinfra/hash.h
index 7d4ed04dc4d..23b91b107a2 100644
--- a/src/vppinfra/hash.h
+++ b/src/vppinfra/hash.h
@@ -93,17 +93,14 @@ typedef struct hash_header
/* Bit i is set if pair i is a user object (as opposed to being
either zero or an indirect array of pairs). */
- uword is_user[0];
+ uword *is_user;
} hash_t;
/* Hash header size in bytes */
always_inline uword
hash_header_bytes (void *v)
{
- hash_t *h;
- uword is_user_bytes =
- (sizeof (h->is_user[0]) * vec_len (v)) / BITS (h->is_user[0]);
- return sizeof (h[0]) + is_user_bytes;
+ return sizeof (hash_t);
}
/* Returns a pointer to the hash header given the vector pointer */