#include <vppinfra/format.h>
#include <vppinfra/pool.h>
#include <vppinfra/cache.h>
+#include <vppinfra/lock.h>
#ifndef BIHASH_TYPE
#error BIHASH_TYPE not defined
u32 log2_nbuckets;
u8 *name;
- u64 cache_hits;
- u64 cache_misses;
-
BVT (clib_bihash_value) ** freelists;
/*
static inline void BV (clib_bihash_alloc_lock) (BVT (clib_bihash) * h)
{
while (__atomic_test_and_set (h->alloc_lock, __ATOMIC_ACQUIRE))
- ;
+ CLIB_PAUSE ();
}
static inline void BV (clib_bihash_alloc_unlock) (BVT (clib_bihash) * h)
locked_bucket.as_u64 = unlocked_bucket.as_u64 = b->as_u64;
unlocked_bucket.lock = 0;
locked_bucket.lock = 1;
+ CLIB_PAUSE ();
}
while (__atomic_compare_exchange_n (&b->as_u64, &unlocked_bucket.as_u64,
locked_bucket.as_u64, 1 /* weak */ ,
int BV (clib_bihash_add_del) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * add_v, int is_add);
+int BV (clib_bihash_add_or_overwrite_stale) (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * add_v,
+ int (*is_stale_cb) (BVT
+ (clib_bihash_kv)
+ *, void *),
+ void *arg);
int BV (clib_bihash_search) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * search_v,
BVT (clib_bihash_kv) * return_v);
{
volatile BVT (clib_bihash_bucket) * bv = b;
while (bv->lock)
- ;
+ CLIB_PAUSE ();
}
hash >>= h->log2_nbuckets;
{
volatile BVT (clib_bihash_bucket) * bv = b;
while (bv->lock)
- ;
+ CLIB_PAUSE ();
}
hash >>= h->log2_nbuckets;