aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/bihash_8_8.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2023-03-16 13:03:47 -0400
committerFlorin Coras <florin.coras@gmail.com>2023-03-18 18:35:46 +0000
commitb9c8c57e983246ec034bc9059b1740558c951d51 (patch)
treecd7267591894b30cea54522fb53ffa1deca1f450 /src/vppinfra/bihash_8_8.h
parent04bd0ea8e22dac53c09e3867cabf6256d19477fa (diff)
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
Diffstat (limited to 'src/vppinfra/bihash_8_8.h')
-rw-r--r--src/vppinfra/bihash_8_8.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/vppinfra/bihash_8_8.h b/src/vppinfra/bihash_8_8.h
index 2fdd2ed7aef..2471871fc81 100644
--- a/src/vppinfra/bihash_8_8.h
+++ b/src/vppinfra/bihash_8_8.h
@@ -44,13 +44,19 @@ typedef struct
u64 value; /**< the value */
} clib_bihash_kv_8_8_t;
+static inline void
+clib_bihash_mark_free_8_8 (clib_bihash_kv_8_8_t *v)
+{
+ v->value = 0xFEEDFACE8BADF00DULL;
+}
+
/** Decide if a clib_bihash_kv_8_8_t instance is free
@param v- pointer to the (key,value) pair
*/
static inline int
clib_bihash_is_free_8_8 (clib_bihash_kv_8_8_t * v)
{
- if (v->key == ~0ULL && v->value == ~0ULL)
+ if (v->value == 0xFEEDFACE8BADF00DULL)
return 1;
return 0;
}