vppinfra: fix corner-cases in bihash lookup
In a case where one pounds on a single kvp in a KVP_AT_BUCKET_LEVEL table, the code would sporadically return a transitional value (junk) from a half-deleted kvp. At most, 64-bits worth of the kvp will be written atomically, so using memset(...) to smear 0xFF's across a kvp to free it left a lot to be desired. Performance impact: very mild positive, thanks to FC for doing a multi-thread host stack perf/scale test. Added an ASSERT to catch attempts to add a (key,value) pair which contains the magic "free kvp" value. Type: fix Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I6a1aa8a2c30bc70bec4b696ce7b17c2839927065
This commit is contained in:
committed by
Florin Coras
parent
04bd0ea8e2
commit
b9c8c57e98
@@ -44,11 +44,16 @@ typedef struct
|
||||
u64 value[7];
|
||||
} clib_bihash_kv_40_56_t;
|
||||
|
||||
static inline void
|
||||
clib_bihash_mark_free_40_56 (clib_bihash_kv_40_56_t *v)
|
||||
{
|
||||
v->value[0] = 0xFEEDFACE8BADF00DULL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
clib_bihash_is_free_40_56 (const clib_bihash_kv_40_56_t *v)
|
||||
{
|
||||
/* Free values are clib_memset to 0xff, check a bit... */
|
||||
if (v->key[0] == ~0ULL && v->value[0] == ~0ULL)
|
||||
if (v->value[0] == 0xFEEDFACE8BADF00DULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ cnat_session_scan (vlib_main_t * vm, f64 start_time, int i)
|
||||
{
|
||||
for (k = 0; k < BIHASH_KVP_PER_PAGE; k++)
|
||||
{
|
||||
if (v->kvp[k].key[0] == ~0ULL && v->kvp[k].value[0] == ~0ULL)
|
||||
if (BV (clib_bihash_is_free) (&v->kvp[k]))
|
||||
continue;
|
||||
|
||||
cnat_session_t *session = (cnat_session_t *) & v->kvp[k];
|
||||
|
||||
Reference in New Issue
Block a user