[ltt-dev] [PATCH 8/9] add duplicated node test
Lai Jiangshan
laijs at cn.fujitsu.com
Sun Nov 13 23:50:58 EST 2011
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
tests/test_urcu_hash.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c
index 3730c2b..964a4e1 100644
--- a/tests/test_urcu_hash.c
+++ b/tests/test_urcu_hash.c
@@ -111,6 +111,7 @@ struct test_data {
struct lfht_test_node {
struct cds_lfht_node node;
unsigned long hash;
+ unsigned long dup;
unsigned long orig_hash;
/* cache-cold for iteration */
struct rcu_head head;
@@ -406,6 +407,8 @@ void lfht_test_node_init(struct lfht_test_node *node)
cds_lfht_next(test_ht, &iter);
if (iter.node)
hash = to_test_node(iter.node)->orig_hash;
+
+ node->dup = test_rand_get_bits(2);
}
node->orig_hash = hash;
@@ -427,6 +430,15 @@ void lfht_test_node_init(struct lfht_test_node *node)
static
int test_match(struct cds_lfht_node *node, void *key)
{
+ struct lfht_test_node *u = to_test_node(node), *v = key;
+
+ if (caa_likely(u->hash != v->hash))
+ return 0;
+
+ /* 56.25% (100% * 9 / 16) duplicated when hash value are the same */
+ if (u->dup && u->dup == v->dup)
+ return 1;
+
return 0;
}
--
1.7.4.4
More information about the lttng-dev
mailing list