aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/pool.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-06-27 10:49:17 -0400
committerDamjan Marion <dmarion@me.com>2018-06-27 20:51:08 +0000
commit0654dcc7b9370be6472f306d0a7b5ba9bf2b7962 (patch)
tree9897db3cf0b58a7085b555cc7a25183a1d0de527 /src/vppinfra/pool.h
parent6e74aa2b9877623c6130d7b2a43b7d8fd0a1b9f8 (diff)
Tune pool_get / pool_put
Stop spending cycles repeatedly tail-trimming the pool free element bitmap; possibly at the expense of slightly hurting pool_foreach peformance. Change-Id: I8a7f3e7b26c71d7496ba9393b2a167dc7f538355 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/pool.h')
-rw-r--r--src/vppinfra/pool.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h
index 0f64262abf1..d1a2be9ddcd 100644
--- a/src/vppinfra/pool.h
+++ b/src/vppinfra/pool.h
@@ -201,8 +201,8 @@ do { \
/* Return free element from free list. */ \
uword _pool_var (i) = _pool_var (p)->free_indices[_pool_var (l) - 1]; \
(E) = (P) + _pool_var (i); \
- _pool_var (p)->free_bitmap = \
- clib_bitmap_andnoti (_pool_var (p)->free_bitmap, _pool_var (i)); \
+ clib_bitmap_set_no_check (_pool_var (p)->free_bitmap, \
+ _pool_var (i), 0); \
_vec_len (_pool_var (p)->free_indices) = _pool_var (l) - 1; \
} \
else \
@@ -220,7 +220,8 @@ do { \
pool_aligned_header_bytes, \
/* align */ (A)); \
E = vec_end (P) - 1; \
- } \
+ pool_validate_index (P, vec_len(P)-1); \
+ } \
} while (0)
/** Allocate an object E from a pool P (unspecified alignment). */
@@ -263,7 +264,7 @@ do { \
({ \
pool_header_t * _pool_var (p) = pool_header (P); \
uword _pool_var (i) = (E) - (P); \
- (_pool_var (i) < vec_len (P)) ? clib_bitmap_get (_pool_var (p)->free_bitmap, _pool_i) : 1; \
+ (_pool_var (i) < vec_len (P)) ? clib_bitmap_get_no_check (_pool_var (p)->free_bitmap, _pool_i) : 1; \
})
/** Use free bitmap to query whether given index is free */
@@ -278,8 +279,9 @@ do { \
ASSERT (! pool_is_free (P, E)); \
\
/* Add element to free bitmap and to free list. */ \
- _pool_var (p)->free_bitmap = \
- clib_bitmap_ori (_pool_var (p)->free_bitmap, _pool_var (l)); \
+ clib_bitmap_set_no_check (_pool_var (p)->free_bitmap, \
+ _pool_var (l), 1); \
+ \
/* Preallocated pool? */ \
if (_pool_var (p)->max_elts) \
{ \