- unsigned long first, unsigned long len)
-{
- unsigned long i, end;
-
- end = first + len;
- for (i = first; i < end; i++) {
- /* Update table size when power of two */
- if (i != 0 && !(i & (i - 1)))
- t->size = i;
- t->tbl[i] = calloc(1, sizeof(struct _rcu_ht_node));
- t->tbl[i]->p.reverse_hash = bit_reverse_ulong(i);
- (void) _ht_add(ht, t, t->tbl[i], 0, 1);
+ unsigned long first_order, unsigned long len_order)
+{
+ unsigned long i, end_order;
+
+ dbg_printf("rculfhash: init table: first_order %lu end_order %lu\n",
+ first_order, first_order + len_order);
+ end_order = first_order + len_order;
+ t->size = !first_order ? 0 : (1UL << (first_order - 1));
+ for (i = first_order; i < end_order; i++) {
+ unsigned long j, len;
+
+ len = !i ? 1 : 1UL << (i - 1);
+ dbg_printf("rculfhash: init order %lu len: %lu\n", i, len);
+ t->tbl[i] = calloc(len, sizeof(struct _rcu_ht_node));
+ for (j = 0; j < len; j++) {
+ dbg_printf("rculfhash: init entry: i %lu j %lu hash %lu\n",
+ i, j, !i ? 0 : (1UL << (i - 1)) + j);
+ struct rcu_ht_node *new_node =
+ (struct rcu_ht_node *) &t->tbl[i][j];
+ new_node->p.reverse_hash =
+ bit_reverse_ulong(!i ? 0 : (1UL << (i - 1)) + j);
+ (void) _ht_add(ht, t, new_node, 0, 1);
+ }
+ /* Update table size */
+ t->size = !i ? 1 : (1UL << i);
+ dbg_printf("rculfhash: init new size: %lu\n", t->size);