From ef6e6171a5046d56c3f4a32abcf3436546977118 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Fri, 28 Oct 2011 08:14:07 +0200 Subject: [PATCH] rculfhash: directly lookup bucket in the first order table [ Edit by Mathieu Desnoyers: add a dbg_printf so the start-of-table lookup prints the same dbg messages as normal lookups. ] Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- rculfhash.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rculfhash.c b/rculfhash.c index 675ef38..1f6ee71 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -738,17 +738,21 @@ struct _cds_lfht_node *lookup_bucket(struct cds_lfht *ht, unsigned long size, assert(size > 0); index = hash & (size - 1); + + if (index < ht->min_alloc_size) { + dbg_printf("lookup hash %lu index %lu order 0 aridx 0\n", + hash, index); + return &ht->t.tbl[0]->nodes[index]; + } /* * equivalent to get_count_order_ulong(index + 1), but optimizes * away the non-existing 0 special-case for * get_count_order_ulong. */ order = fls_ulong(index); - dbg_printf("lookup hash %lu index %lu order %lu aridx %lu\n", - hash, index, order, index & (!order ? 0 : ((1UL << (order - 1)) - 1))); - - return &ht->t.tbl[order]->nodes[index & (!order ? 0 : ((1UL << (order - 1)) - 1))]; + hash, index, order, index & ((1UL << (order - 1)) - 1)); + return &ht->t.tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)]; } /* -- 2.34.1